New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undefined behaviour warning that looks like a false positive? #2786
Comments
Could you provide more complete example? I can't reproduce it - that's how I'm trying it: here I suspect that compiler is not wrong, i.e. with 4 wide target all active program instances will be writing to the same location... but where will be only one of them :) But I'm not able to reproduce. |
@dbabokin I suspect that it is as you say - the target where we get the warning is 4-wide. A little tweak and I was able to reproduce the warning: https://godbolt.org/z/dbns4c33M I agree that the statement is technically correct but is it really undefined behaviour to have a single program instance writing to a single location? I suspect that it is not. ;) |
Thanks for the reproducer!
Absolutely, it needs to be fixed, it looks like and corner case at this point. |
I also discovered the same false-positive warning in my application. Consider a 1D array of vector3 in the Array-of-Struct layout, commonly found in legacy code:
To access a single vector of
The compiler thinks it's okay, and only generates gather-scatter warnings. However, as soon as the compile-time constant
Now false-positive warnings are generated:
Clearly, if the value of |
I have a function that calculates a result across each set of 4 lanes. I then write out the value for each set of 4 lanes:
However, when I compile, I get the following warning:
As I see it, only the lanes where
Element
is 0, 4, 8 or 12 are active, and they will write to indices 0, 1, 2 and 3 in the output buffer so I'm not sure that I should be getting the warning? Unless I have missed something (which is always possible, of course!)The text was updated successfully, but these errors were encountered: