This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: reference to volatile becomes itself volatile


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]