[cfe-dev] C++ and volatile lvalue-to-rvalue
abramo.bagnara at gmail.com
Thu Oct 13 04:43:11 PDT 2011
I want to put this gcc bug report to clang developer attention.
The gcc developers believe that according to the standard
volatile int v;
x = v = 3;
does not imply necessarily a read from v.
clang instead add a lvalue-to-rvalue implicit cast outside v = 3
assignment (and there is general consensus that lvalue-to-rvalue *is*
the marker for memory read access).
If the beliefs of gcc developers are agreed by clang developers I think
that the cast kind should be changed in something else (and codegen
might handle this new kind differently).
Otherwise we should conclude that clang is right and gcc miscompile the
Note that the difference is not theoretic, just suppose that v is an
hardware register that when written is reset and when read return the
Of course the code above might be written as
v = 3;
x = v;
but this is pointless when trying to understand what is the right
semantic of C++ language as designed by the relevant standards.
More information about the cfe-dev