reference to volatile becomes itself volatile
Ian Lance Taylor
iant@google.com
Fri Jul 29 04:25:00 GMT 2011
Kalle Olavi Niemitalo <kon@iki.fi> writes:
> Compiling the following with Debian g++ 4.4.5-8 on x86_64, using
> -m64 -fno-exceptions -O2 -S:
>
> static volatile char &ref_to_volatile =
> *reinterpret_cast<char *>(10000000000);
> char
> increment_at_ref_to_volatile()
> {
> return ++ref_to_volatile;
> }
>
> generates code that first reads the reference from memory and
> then accesses the volatile char thrice.
I see that too with 4.4. However, it appears to be fixed in 4.5.
Ian
More information about the Gcc-help
mailing list