comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: for X'Address use - and Volatile
Date: Wed, 31 Aug 2016 06:01:36 -0700 (PDT)
Date: 2016-08-31T06:01:36-07:00	[thread overview]
Message-ID: <7595494c-3398-4fd9-ab4b-80a79383ae33@googlegroups.com> (raw)

Hi,

Consider:

X : Integer;
Y : Integer;
for Y'Address use X'Address;

The above is a simple overlay, typically used for under-the-table type conversions.

AARM 13.3 says:

"If the Address of an object is specified [...], then the implementation should not perform optimizations based on assumptions of no aliases."

Interestingly, in the above example there are two objects involved in the overlay, yet only one (Y) is affected by this rule (becaue Address is *specified* only for Y, not for X). Let's assume that this is an omission and that the intent is that both object (X and Y) should be excluded from such optimizations, otherwise it will not work.

The question is - do we need pragma Volatile on these objects as well?

C.6 (16c/3):
"If for a shared variable X, a read of X occurs sequentially after an update of X, then the read will return the updated value if X is volatile or atomic, but may or or may not return the updated value if X is nonvolatile."

My understanding is that Volatile is *not* needed to ensure proper working of this overlay, even though C.6 seems to imply otherwise. My feeling is that C.6 focuses on data sharing between tasks only and in the case of overlays, the lack of non-aliasing optimizations is enough.

The question comes from analyzing of the code which contains such an overlay together with pragma Volatile. This is a single-tasking program.
My feeling is that Volatile is superfluous - unless there are other reasons for it, for example related to I/O register mapping, etc.

-- 
Maciej Sobczak * http://www.inspirel.com


             reply	other threads:[~2016-08-31 13:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-31 13:01 Maciej Sobczak [this message]
2016-08-31 14:00 ` for X'Address use - and Volatile AdaMagica
2016-08-31 19:36 ` Randy Brukardt
2016-08-31 22:17   ` Maciej Sobczak
2016-09-01  1:22     ` Randy Brukardt
2016-09-01  5:41     ` Simon Wright
2016-09-01 14:24       ` Maciej Sobczak
2016-09-01  8:12   ` J-P. Rosen
replies disabled

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