This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: reference to volatile becomes itself volatile
- From: Ian Lance Taylor <iant at google dot com>
- To: Kalle Olavi Niemitalo <kon at iki dot fi>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Thu, 28 Jul 2011 21:24:49 -0700
- Subject: Re: reference to volatile becomes itself volatile
- References: <87ei1axhpb.fsf@Pulska.kon.iki.fi>
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