This is the mail archive of the 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: [PATCH] Preserve volatileness, fix PR32721

On Fri, 13 Jul 2007, Diego Novillo wrote:

> On 7/13/07 8:52 AM, Richard Guenther wrote:
> > int spinlock[2];
> > void foo()
> > {
> >   volatile int *x = &spinlock[0];
> >   *x = 1;
> >   while (*x)
> >     ;
> > }
> > 
> > we managed to preserve the volatileness of the accesses through *x in
> > previous releases.  Now we don't, maybe as part of the change of
> > early optimizations.
> Hmm?  AFAIU, *x is *not* volatile, only the pointer is.  So, *x = 1
> ought to be fair game.
> Is this an extension or something undefined in the standard?


  volatile int *x;

is a declaration of a pointer _to_ a volatile int.  So


is an access to a volatile int.  We were (at least in the past)
trying to preserve this volatileness of this access (the standard is
not very clear about this, so you may call this an (undocumented)
gcc extension).

(The standard is of course clear in that spinlock[0] is not a volatile
access, so if we propagate &spinlock[0] into *x as we do (and I don't
see how we should not), we need to preserve the volatileness of the
access.  Iff we agree on this "extension", which IMHO is pretty
reasonable, as it just preserves what is considered a volatile
access by the C standard in the original source).


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