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=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.ecp.fr!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Oberon and Wirthian languages Date: Tue, 22 Apr 2014 18:38:32 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <1ljwj8f.1wqbhvuabsdw1N%csampson@inetworld.net> <51c7d6d4-e3be-44d5-a4ce-f7e875345588@googlegroups.com> <%J32v.70539$kp1.45343@fx14.iad> <8761m535e4.fsf_-_@ludovic-brenta.org> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1398209913 7597 69.95.181.76 (22 Apr 2014 23:38:33 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 22 Apr 2014 23:38:33 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: number.nntp.dca.giganews.com comp.lang.ada:185951 Date: 2014-04-22T18:38:32-05:00 List-Id: "Simon Clubley" wrote in message news:lj6kfg$jhs$1@dont-email.me... ... > Ok, now that's interesting. I would not have assumed the compiler would > do the read multiple times in this specific case. > > I would have assumed the Volatile attribute would be satisfied in this > specific case by doing the read _once_ at the start of the generated > code and only generating code to modify the A, B and C bitfields > before writing everything back in one step by using a single store > opcode. C.6(20): The external effect of a program (see 1.1.3) is defined to include each read and update of a volatile or atomic object. The implementation shall not generate any memory reads or updates of atomic or volatile objects other than those specified by the program. I see two reads of Rec in the original source code. The above rule means that an Ada compiler must NOT combine those reads for convinience; it must do EXACTLY what's in the source code. If you only want one read, you have to restructure so there is only one explicit read. There was a long discussion about this some years ago, and the conclusion was that combining operations in particular is not allowed for volatile objects (and all atomic objects are also volatile). Randy.