delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2006/03/28/06:00:47

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "Bob W" <dontsend AT operamail DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: new gcc 4.10 behaviour
Date: 28 Mar 2006 02:47:27 -0800
Organization: http://groups.google.com
Lines: 49
Message-ID: <1143542847.613686.87820@v46g2000cwv.googlegroups.com>
NNTP-Posting-Host: 84.102.38.180
Mime-Version: 1.0
X-Trace: posting.google.com 1143542852 2797 127.0.0.1 (28 Mar 2006 10:47:32 GMT)
X-Complaints-To: groups-abuse AT google DOT com
NNTP-Posting-Date: Tue, 28 Mar 2006 10:47:32 +0000 (UTC)
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse AT google DOT com
Injection-Info: v46g2000cwv.googlegroups.com; posting-host=84.102.38.180;
posting-account=CXf2IQ0AAADhHwR4LIBYSPHMQKV3cPd3
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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.

- Raw text -


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