This is the mail archive of the gcc@gcc.gnu.org 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: Heads-up: volatile and C++


On Thu, 2005-04-14 at 23:33 +0200, Jason Merrill wrote:
> On Thu, 14 Apr 2005 15:47:44 -0500, Robert Dewar <dewar@adacore.com> wrote:
> > [Ada standard]
> 
> Yep, sounds a lot like C/C++: volatile reads and writes are required to
> have sequential ordering relative to each other, but (outside the current
> thread) they are not ordered relative to non-volatile reads and writes.

Here's an extract from section 9.10 ("sequential"):

15.a
Ramification: If two actions are ``sequential'' it is known that their executions
don't overlap in time, but it is not necessarily specified which occurs first. For
example, all actions of a single task are sequential, even though the exact order
of execution is not fully specified for all constructs. 
15.b
Discussion: Note that if two assignments to the same variable are sequential, but
neither signals the other, then the program is not erroneous, but it is not specified
which assignment ultimately prevails. Such a situation usually corresponds to a
programming mistake, but in some (rare) cases, the order makes no difference, and for
this reason this situation is not considered erroneous nor even a bounded error. In
Ada 83, this was considered an ``incorrect order dependence'' if the ``effect'' of the
program was affected, but ``effect'' was never fully defined. In Ada 95, this situation
represents a potential nonportability, and a friendly compiler might want to warn the
programmer about the situation, but it is not considered an error. An example where
this would come up would be in gathering statistics as part of referencing some
information, where the assignments associated with statistics gathering don't need to
be ordered since they are just accumulating aggregate counts, sums, products, etc.

Ciao,

Duncan.


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