comp.lang.ada
 help / color / mirror / Atom feed
* for X'Address use - and Volatile
@ 2016-08-31 13:01 Maciej Sobczak
  2016-08-31 14:00 ` AdaMagica
  2016-08-31 19:36 ` Randy Brukardt
  0 siblings, 2 replies; 8+ messages in thread
From: Maciej Sobczak @ 2016-08-31 13:01 UTC (permalink / 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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-09-01 14:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-31 13:01 for X'Address use - and Volatile Maciej Sobczak
2016-08-31 14:00 ` 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

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