From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Received: by 10.107.162.16 with SMTP id l16mr3350632ioe.18.1472648496561; Wed, 31 Aug 2016 06:01:36 -0700 (PDT) X-Received: by 10.157.31.88 with SMTP id x24mr832572otx.4.1472648496527; Wed, 31 Aug 2016 06:01:36 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!i184no38144itf.0!news-out.google.com!n186ni1178ith.0!nntp.google.com!e124no36630ith.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 31 Aug 2016 06:01:36 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=165.225.80.105; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S NNTP-Posting-Host: 165.225.80.105 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7595494c-3398-4fd9-ab4b-80a79383ae33@googlegroups.com> Subject: for X'Address use - and Volatile From: Maciej Sobczak Injection-Date: Wed, 31 Aug 2016 13:01:36 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:31658 Date: 2016-08-31T06:01:36-07:00 List-Id: 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 conv= ersions. AARM 13.3 says: "If the Address of an object is specified [...], then the implementation sh= ould not perform optimizations based on assumptions of no aliases." Interestingly, in the above example there are two objects involved in the o= verlay, yet only one (Y) is affected by this rule (becaue Address is *speci= fied* only for Y, not for X). Let's assume that this is an omission and tha= t the intent is that both object (X and Y) should be excluded from such opt= imizations, 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 updat= e of X, then the read will return the updated value if X is volatile or ato= mic, 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 th= at C.6 focuses on data sharing between tasks only and in the case of overla= ys, the lack of non-aliasing optimizations is enough. The question comes from analyzing of the code which contains such an overla= y 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. --=20 Maciej Sobczak * http://www.inspirel.com