Bug#164554: gcc-3.2: volatile not respected on alpha
On Mon, Oct 14, 2002 at 10:31:03PM -0400, Daniel Jacobowitz wrote:
> On Tue, Oct 15, 2002 at 12:09:56PM +1000, Herbert Xu wrote:
> > On Mon, Oct 14, 2002 at 07:01:46PM -0400, Daniel Jacobowitz wrote:
> > >
> > > > My copy of C99 says:
> > > >
> > > > 5 The least requirements on a conforming implementation are:
> > > > - At sequence points, volatile objects are stable in the sense that previou
> > > > s accesses are
> > > > complete and subsequent accesses have not yet occurred.
> > >
> > > Only volatile objects are required to be stable. I believe that if "j"
> >
> > That's right. However, there is a sequence point between i++ and
> > j=6, so the previous access to i should be completed at that point.
>
> But the value of J is not required to coordinate with any sequence
> points in the implementation, only in the abstract machine...
>
>
> I have (6.7.3 #6)
> Furthermore, at every sequence point the value last stored
> in the object shall agree with that prescribed by the
> abstract machine, except as modified by the unknown factors
> mentioned previously.114) What constitutes an access to an
> object that has volatile-qualified type is implementation-
> defined.
>
> But that paragraph explicitly applies only to volatile qualified types.
BTW, look at asm/spinlock.h: this is why there are __volatile__ markers
on the asm, and a "memory" clobber. The clobber prevents the following
instructions from being moved before the spinlock is taken.
It's worse than that: on a machine with out-of-order memory accesses,
your testcase would obviously lose unless GCC inserted explicit memory
barriers, and I don't believe it's ever required to do that.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
Reply to: