delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2006/03/29/07:46:16

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: new gcc 4.10 behaviour
Date: 29 Mar 2006 12:34:54 GMT
Lines: 22
Message-ID: <48vd7eFm0rukU5@news.dfncis.de>
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>
X-Trace: news.dfncis.de hC+Xiw6+6ppKX3MXpXcW2QvMt1WhCuCXqtC7tG9KgzpBSQnZUBF5Yej+Rh
X-Orig-Path: not-for-mail
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Martin Steuer <martin AT x DOT invalid> wrote:

> 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 would appear to be a side effect of the C99 feature allowing
variable definitions to occur in the middle of a block, rather than at
the start of it only.

-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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