Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Clang warning: using the result of an assignment as a condition #219

Closed
andrewcorrigan opened this issue Oct 19, 2020 · 1 comment · Fixed by #220
Closed

Clang warning: using the result of an assignment as a condition #219

andrewcorrigan opened this issue Oct 19, 2020 · 1 comment · Fixed by #220
Labels
good first issue Good for newcomers. type: bug: functional Does not work as intended.
Milestone

Comments

@andrewcorrigan
Copy link
Contributor

An assignment within an if-statement introduced in [bac2060] triggers a warning with Clang:

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 warning
                if (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 comparison
                if (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)
@alliepiper
Copy link
Collaborator

Would it make sense to split this into two lines?

Sounds good to me.

@alliepiper alliepiper added the good first issue Good for newcomers. label Oct 19, 2020
@alliepiper alliepiper added this to the 1.11.1 milestone Oct 19, 2020
andrewcorrigan pushed a commit to andrewcorrigan/cub that referenced this issue Oct 19, 2020
andrewcorrigan pushed a commit to andrewcorrigan/cub that referenced this issue Oct 19, 2020
andrewcorrigan added a commit to andrewcorrigan/cub that referenced this issue Oct 19, 2020
@alliepiper alliepiper modified the milestones: 1.11.1, 1.11.0 Oct 21, 2020
@alliepiper alliepiper added the type: bug: functional Does not work as intended. label Oct 21, 2020
alliepiper pushed a commit that referenced this issue Nov 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers. type: bug: functional Does not work as intended.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants