comp.lang.ada
 help / color / mirror / Atom feed
From: Eric Hughes <eric.eh9@gmail.com>
Subject: Semantics of statement reordering relevant to Ada.Real_Time
Date: Sun, 30 Mar 2008 10:12:25 -0700 (PDT)
Date: 2008-03-30T10:12:25-07:00	[thread overview]
Message-ID: <c3842c8b-f3a3-49be-b218-02045f9153ea@i7g2000prf.googlegroups.com> (raw)
In-Reply-To: f64ef241-4d24-4632-a6b9-13b7052d04e2@e23g2000prf.googlegroups.com

On Mar 29, 7:51 am, kongra <kon...@gmail.com> 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



  parent reply	other threads:[~2008-03-30 17:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-29 13:51 Ada.Real_Time behavior with GNAT kongra
2008-03-29 16:50 ` george.priv
2008-03-29 17:29   ` Georg Bauhaus
2008-03-29 19:06     ` george.priv
2008-03-29 19:15     ` Konrad Grzanek
2008-03-29 18:11 ` Simon Wright
2008-03-29 18:25 ` Dmitry A. Kazakov
2008-03-29 19:46   ` Konrad Grzanek
2008-03-29 21:21     ` george.priv
2008-03-29 21:49       ` Konrad Grzanek
2008-03-30  0:14     ` Georg Bauhaus
2008-03-30 17:12 ` Eric Hughes [this message]
2008-03-30 18:59   ` Semantics of statement reordering relevant to Ada.Real_Time Robert A Duff
2008-03-30 21:12     ` Eric Hughes
2008-03-30 21:28       ` Robert A Duff
replies disabled

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