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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,101c38a932801b81 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!postnews.google.com!i7g2000prf.googlegroups.com!not-for-mail From: Eric Hughes Newsgroups: comp.lang.ada Subject: Semantics of statement reordering relevant to Ada.Real_Time Date: Sun, 30 Mar 2008 10:12:25 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 166.70.57.218 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1206897146 31203 127.0.0.1 (30 Mar 2008 17:12:26 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 30 Mar 2008 17:12:26 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: i7g2000prf.googlegroups.com; posting-host=166.70.57.218; posting-account=5RIiTwoAAACt_Eu87gmPAJMoMTeMz-rn User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20643 Date: 2008-03-30T10:12:25-07:00 List-Id: On Mar 29, 7:51 am, kongra wrote: > Start_T := Ada.Real_Time.Clock; > for K in 1 .. 10 loop > for I in 1 .. 10_000_000 loop > Val := Val + I; > end loop; > end loop; > End_T := Ada.Real_Time.Clock; I have a question about this piece of the program. Because the middle uses only variables 'K', 'I', and 'Val', and the side-effects of modifying these variables are entirely local, and because there's no inter-dependency of these variables upon either the first or last statements, aren't the following reorderings legal for code generation? To wit: Long_Statement ; Start_T := Ada.Real_Time.Clock ; End_T := Ada.Real_Time.Clock ; Start_T := Ada.Real_Time.Clock ; End_T := Ada.Real_Time.Clock ; Long_Statement ; Irrelevant to the quirks mentioned earlier, isn't it legal operation for the interval to come out zero? It seems that for known-correct operation for all possible compilers you'd need to manually serialize these operations in the order desired. Eric