delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2006/04/06/12:31:43

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Trace-PostClient-IP: 68.147.232.190
From: Brian Inglis <Brian DOT Inglis AT SystematicSW DOT Invalid>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Sequence points, any?
Organization: Systematic Software
Message-ID: <sofa3296m70vcfeo93regapfuis5qutsao@4ax.com>
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>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Lines: 38
Date: Thu, 06 Apr 2006 16:29:06 GMT
NNTP-Posting-Host: 64.59.135.176
X-Complaints-To: abuse AT shaw DOT ca
X-Trace: pd7tw2no 1144340946 64.59.135.176 (Thu, 06 Apr 2006 10:29:06 MDT)
NNTP-Posting-Date: Thu, 06 Apr 2006 10:29:06 MDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On 6 Apr 2006 08:50:04 GMT in comp.os.msdos.djgpp, Hans-Bernhard
Broeker <broeker AT physik DOT rwth-aachen DOT de> wrote:

>Brian Inglis <Brian DOT Inglis AT systematicsw DOT invalid> wrote:
>
>> The compiler should not be rearranging the order of calls to external
>> functions specified in separate statements, unless there were some
>> other factors involved that it could infer. 
>
>Well --- it's not rearranging calls to external functions, since Ack()
>is not exactly an external function in the example case.  The only
>calls to external functions are those to clock() and printf(), in that
>example, and those are left in their original order.  The only strange
>thing is that GCC apparently detected that Ack() and clock() were
>independent jobs that could be done in parallel, since the result of
>one could not possibly depend on whether the other was finished yet.
>So it expanded Ack() inline (at least partially), and put the call to
>clock right in the middle of it.  
>
>Unfortunately, that detection is wrong for a function like clock().  I
>may be going out on a limb there, but this could require a change to
>the declaration of clock() and similar functions to forbid this kind
>of optimization.

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: even declaring the internal function static did not change
the code. If the compiler had inlined or reorganized the internal
function better, I could understand why it did what it did, but when
the workaround is declaring an auto variable (local) static, looks to
me like a bug: something is toggled the wrong way here. 

-- 
Thanks. Take care, Brian Inglis 	Calgary, Alberta, Canada

Brian DOT Inglis AT CSi DOT com 	(Brian[dot]Inglis{at}SystematicSW[dot]ab[dot]ca)
    fake address		use address above to reply

- Raw text -


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