Greg Stark <stark(at)mit(dot)edu> writes:
> The confusion for me is that it's talking about sequence points and
> volatile pointers in the same breath as if one implies the other.
> Making something a volatile pointer dose not create a sequence point.
> It requires that the compiler not move the access or store across any
> sequence points that are already there.
Well, no, I don't think that's the useful way to think about it. Modern
compilers seem to only honor sequence points in terms of the semantics
seen by the executing program; they don't believe that they can't
reorder loads/stores freely. And as long as the memory in question is
only used by the given program, they're right. But for memory locations
shared with other threads of execution, you have to be careful about the
order of accesses to those locations. My understanding of "volatile"
is that the compiler is forbidden from altering the order of
volatile-qualified loads and stores *relative to each other*, or from
optimizing away a load or store that seems redundant in the context of
the given program. That's got nothing to do with sequence points per se.
> It might be helpful to include the actual bug that the comment is
> trying to warn against because iirc it was a real case that caused you
> to add the volatile modifiers.
Well, if there were one and only one bug involved here, it wouldn't be
such a critical problem ...
regards, tom lane
In response to
pgsql-hackers by date
|Next:||From: Tom Lane||Date: 2011-08-29 16:42:14|
|Subject: Re: Join push-down for foreign tables |
|Previous:||From: Greg Stark||Date: 2011-08-29 15:48:23|
|Subject: Re: spinlocks on HP-UX|