public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Volatile qualification on pointer and data
@ 2011-09-20 16:08 Paulo J. Matos
  2011-09-20 16:36 ` Ian Lance Taylor
  0 siblings, 1 reply; 30+ messages in thread
From: Paulo J. Matos @ 2011-09-20 16:08 UTC (permalink / raw)
  To: gcc

Hi,

I am noticing a very concerning change of behaviour from GCC45 to GCC46 
on our applications.

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 noticed that this seems to be implementation dependent according to 
C99 6.7.3.6, however, this change of implementation is unexpected and I 
don't see a reason for it. Is there any reason for this change?

The correct code is generated is both the pointer and data are qualified 
as volatile even it is not straightforward code since it has some moves 
to and from the stack pointer.

This is easily reproducible in i386 so, it's definitely not backend 
specific.

Cheers,
-- 
PMatos

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2011-09-26  7:41 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-20 16:08 Volatile qualification on pointer and data Paulo J. Matos
2011-09-20 16:36 ` Ian Lance Taylor
2011-09-21  7:07   ` David Brown
2011-09-21  8:22     ` Paulo J. Matos
2011-09-21 10:20       ` David Brown
2011-09-21 13:57         ` Ian Lance Taylor
2011-09-21 14:25           ` David Brown
2011-09-21 14:57             ` Paulo J. Matos
2011-09-22  8:39               ` David Brown
2011-09-22 21:15               ` Richard Guenther
2011-09-23 11:33                 ` Paulo J. Matos
2011-09-23 11:51                   ` Paulo J. Matos
2011-09-23 13:17                 ` Paulo J. Matos
2011-09-21 18:51             ` Georg-Johann Lay
2011-09-22  8:53               ` David Brown
2011-09-24 15:10                 ` John Regehr
2011-09-24 15:49                   ` David Brown
2011-09-24 16:26                     ` David Brown
2011-09-24 19:38                     ` John Regehr
2011-09-25 13:03                       ` David Brown
2011-09-25 15:15                         ` Andreas Schwab
2011-09-25 16:33                           ` David Brown
2011-09-25 16:36                             ` David Brown
2011-09-25 16:06                         ` Dave Korn
2011-09-25 22:05                           ` David Brown
2011-09-25 22:05                             ` David Brown
2011-09-26  7:14                             ` Miles Bader
2011-09-26  8:53                               ` David Brown
2011-09-26  8:58                                 ` David Brown
2011-09-21  8:14   ` Paulo J. Matos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).