comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: volatile vs volatile_components
Date: Wed, 5 Nov 2008 17:21:25 -0800 (PST)
Date: 2008-11-05T17:21:25-08:00	[thread overview]
Message-ID: <249486d2-c000-483f-af5b-4938ba6ccc51@b2g2000prf.googlegroups.com> (raw)
In-Reply-To: 046f172d-90f7-4a23-a181-dd1461ebd94b@i18g2000prf.googlegroups.com

On Nov 5, 7:00 am, REH <spamj...@stny.rr.com> wrote:
> Is there a difference between defining an array with pragma volatile
> vs volatile_components? The standard says that if the object is
> volatile, its components are volatile. So, if the object is defined as
> having volatile components, what does that say--if anything--about the
> object as a whole?

Good question.  With Volatile_Components, the simple answer would be
that the array components are volatile but the array object as a whole
is not.  But after studying C.6, I have to admit that this doesn't
make much sense.  The purpose of Volatile is to make sure all reads
and writes of a volatile object are done exactly as the program tells
it to (no optimizing away of "redundant" loads, for instance); and if
you declare an array's subcomponents to be Volatile, you want reads
and writes of the components to occur just as the program says to do
them, and I'd think that reading and writing the entire array, since
it has volatile components, would mean that the array reads/writes
would also have to take place just like the program says, in order for
the desired effect to happen on the volatile components.  In other
words, I can't think of a single case where an operation on an array
that has Volatile_Components but not Volatile specified should behave
differently than the same operation on a Volatile array.

                                  -- Adam



  reply	other threads:[~2008-11-06  1:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-05 15:00 volatile vs volatile_components REH
2008-11-06  1:21 ` Adam Beneschan [this message]
2008-11-06  9:25   ` Dmitry A. Kazakov
2008-11-06 16:23     ` Adam Beneschan
2008-11-06 10:18 ` Stuart
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox