警告的意思 :使用了表达式的结果作为条件判断的变量
GCC还是希望代码尽量的没有争议,将表达式的结果去进行判断。
改法 :先将表达式的结果计算出来,在传入 if ,for,while 之类的()里面去
if (payload.error = std::forward<Invocable>(f)(payload.attribute))
改为
payload.error = std::forward<Invocable>(f)(payload.attribute);
if (payload.error)
https://github.com/NVIDIA/cub/issues/219
In file included from /thrust/cub/block/../iterator/cache_modified_input_iterator.cuh:42:
/thrust/cub/block/../iterator/../util_device.cuh:323:35: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]if (payload.error = std::forward<Invocable>(f)(payload.attribute))~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/thrust/cub/block/../iterator/../util_device.cuh:323:35: note: place parentheses around the assignment to silence this warningif (payload.error = std::forward<Invocable>(f)(payload.attribute))^( )
/thrust/cub/block/../iterator/../util_device.cuh:323:35: note: use '==' to turn this assignment into an equality comparisonif (payload.error = std::forward<Invocable>(f)(payload.attribute))^==Would it make sense to split this into two lines?payload.error = std::forward<Invocable>(f)(payload.attribute);if (payload.error)