This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Volatile qualification on pointer and data
- From: Ian Lance Taylor <iant at google dot com>
- To: "Paulo J. Matos" <paulo at matos-sorge dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 20 Sep 2011 09:35:41 -0700
- Subject: Re: Volatile qualification on pointer and data
- References: <j5adnq$bb4$1@dough.gmane.org>
"Paulo J. Matos" <paulo@matos-sorge.com> writes:
> The following code:
> static const unsigned int foo = 1;
> unsigned int test( void )
> {
> const volatile unsigned int *bar = &foo;
> return ( *bar );
> }
>
> in GCC45 works as expected:
> $test:
> ld AL,#foo ;; AL is return register
> bra 0,X ;; end function
>
> in GCC46:
> $test:
> ld AL,0
> bra 0,X
>
> This is worrying because qualifying the data as volatile should be
> enough to prevent these sort of optimizations. It did until GCC46.
I agree that this looks like a bug. Please file a bug report marked as
a regression.
Ian