delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2006/04/01/10:47:57

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Date: Sat, 1 Apr 2006 17:20:48 +0200
From: Egon Eckert <egon AT heaven DOT industries DOT cz>
To: djgpp AT delorie DOT com
Subject: Re: new gcc 4.10 behaviour
Message-ID: <20060401152048.GA7360@heaven.industries.cz>
References: <1143542847 DOT 613686 DOT 87820 AT v46g2000cwv DOT googlegroups DOT com> <48sjvaFlir4cU1 AT news DOT dfncis DOT de> <48v4k4Fm65abU1 AT news DOT dfncis DOT de> <48vd7eFm0rukU5 AT news DOT dfncis DOT de>
MIME-Version: 1.0
In-Reply-To: <48vd7eFm0rukU5@news.dfncis.de>
User-Agent: Mutt/1.5.11
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> > And if not, why? Would the optimizer have to assume that the first call 
> > to clock has changed the internal state of that function?
> 
> Generally it would --- but not if the two calles are initializers of
> variables.
> 
> > And in general: how can one guarantee a certain order of execution for 
> > code like that from the OP? 
> 
> By making them statements, rather than series of variable definitions.
> That changes introduces what the C standard calls "sequence points",
> which the optimizer must respect, and thus maintains order of things.

This only makes my confusion worse.  According to

http://en.wikipedia.org/wiki/Sequence_point

initializers constitute sequence points ("9. At the end of an
initializer.").  So in the case

int a = clock();
// ...
int b = clock();

the compiler should (IMHO) never be allowed to reorder these two.  Or
am I missing something?  Or is Wikipedia wrong, *again*? :)

Egon

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019