delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2006/04/06/16:01:21

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: Sequence points, any?
Date: 6 Apr 2006 19:54:38 GMT
Lines: 29
Message-ID: <49l9vtFpguvkU1@news.dfncis.de>
References: <1144238453 DOT 674596 DOT 302360 AT z34g2000cwc DOT googlegroups DOT com> <200604051406 DOT k35E6iOx002313 AT envy DOT delorie DOT com> <1144285170 DOT 583086 DOT 24610 AT v46g2000cwv DOT googlegroups DOT com> <v1v832h6p1p2bn51mjva71bkg6aui4in9n AT 4ax DOT com> <49k31sFovesfU3 AT news DOT dfncis DOT de> <sofa3296m70vcfeo93regapfuis5qutsao AT 4ax DOT com>
X-Trace: news.dfncis.de D7PnJr55WxI1eTNGpthzxwVfPCFeuLwbLX1YZsumiDv5h6MTeH49hxt0pE
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

Brian Inglis <Brian DOT Inglis AT systematicsw DOT invalid> wrote:

> That kind of optimization is forbidden unless the (external) function
> is declared with attributes pure or const (clock is not), or the
> compiler can sufficiently determine the effect of the (internal)
> function: 

The latter is the case.  The Ack() function in the example is
completely self-contained, changes no static variables or has any
other effect that any other function could possibly depend on ---
except if that other function depends on volatile variables, which
clock() happens to do.  I.e. Ack() is a "pure" function, in terms of
GCC attributes.  For all the C standard is concerned, Ack() could be
precomputed at compile time and implemented as a lookup table for all
arguments below some threshold.

OTOH, clock() isn't exactly deterministic to begin with, so there's no
new indetermination added by this optimization --- it's just a
gradual, not a qualitative change.

> even declaring the internal function static did not change the code.

That's because the compiler has determined already by itself that this
call of the function can be treated as if it had internal linkage
(i.e. as if it were declared static), and partially inlined it.

-- 
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