delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2006/04/04/22:46:37

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: new gcc 4.10 behaviour
Organization: Systematic Software
Message-ID: <mva632ppkl4tg0qvuk2ce3eb3m0mfvo4of@4ax.com>
References: <1143542847 DOT 613686 DOT 87820 AT v46g2000cwv DOT googlegroups DOT com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Lines: 62
Date: Wed, 05 Apr 2006 02:40:31 GMT
NNTP-Posting-Host: 64.59.135.176
X-Complaints-To: abuse AT shaw DOT ca
X-Trace: pd7tw3no 1144204831 64.59.135.176 (Tue, 04 Apr 2006 20:40:31 MDT)
NNTP-Posting-Date: Tue, 04 Apr 2006 20:40:31 MDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On 28 Mar 2006 02:47:27 -0800 in comp.os.msdos.djgpp, "Bob W"
<dontsend AT operamail DOT com> wrote:

>After suspecting that something around the clock()
>function is flawed in the new release of gcc 4.10,
>DJ's and Brian's posts to my previous thread have
>convinced me that the problem is not that simple.
>
>The following program was simplified as much as possible
>and it should be run with a command line parameter of
>11 or 12 (based on a 2GHz P4) to verify the effects:
>------------------
>
>#include <stdio.h>
>#include <stdlib.h>
>#include <time.h>
>
>int Ack(int m, int n) {
>  return(m ? (Ack(m-1,n ? Ack(m,(n-1)) : 1)) : n+1);
>}
>
>int main(int ac, char **av) {
>  int n = (ac == 2) ? atoi(av[1]) : 1;
>  clock_t t0=clock();
>  int ackret=Ack(3, n);
>  clock_t t1=clock();
>
>  printf("Ack(3,%d): %d\n", n, ackret);
>  printf("Time: %g secs\n", 1.0*(t1-t0)/CLOCKS_PER_SEC);
>  printf("t1:%d, t0:%d, cps:%d\n",t1,t0,CLOCKS_PER_SEC);
>
>  return 0;
>}
>
>------------------
>
>Findings:
>- If compiled without optimisation the program is obviously slow,
>  but it seems to work as it did with gcc 4.01.
>- Every optimisation level from -O to -O3 gives various problems,
>  depending on the value of the command line parameter:
>  - Wrong value returned by clock().  - OR -
>  - Program terminates without message.
>
>Workaround:
>- Variable "ackret" must be declared static or made global.
>
>Conclusion:
>  Maybe I should just wait for gcc 4.20 and use 4.01 in the
>  meanwhile. In any case I would be grateful if someone could
>  explain to me what is going on with gcc 4.10.

Didn't see anything similar reported against gcc 4; would be worth
reporting a bug, for the case with the command line causing an
incorrect reordering, to ensure that a fix gets worked on:
http://gcc.gnu.org/bugzilla/enter_bug.cgi

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