www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/19/22:01:44

From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Uclock & Clock causing SIG error w/O3 and greater
Date: Sat, 19 Jul 1997 15:50:13 -0400
Organization: Cornell University http://www.cornell.edu
Lines: 37
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <33D11A75.39E2@cornell.edu>
References: <33CFAD70 DOT 1366 AT lausd DOT k12 DOT ca DOT us> <5qqmfa$r5v$1 AT news-hrz DOT uni-duisburg DOT de>
Reply-To: asu1 AT cornell DOT edu
NNTP-Posting-Host: cu-dialup-0094.cit.cornell.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Michael Mauch wrote:
> 
> On Fri, 18 Jul 1997 17:53:17 GMT, csantill AT lausd DOT k12 DOT ca DOT us wrote:

> > SIGFPE error(division by zero) at line 54:
> >
> > fps=7680/((t[2]-t[1])/UCLOCKS_PER_SEC)
> >                 or
> > fps=7680/((t[2]-t[1])/CLOCKS_PER_SEC)
> >
> > This is odd because it does not occur when I compile
> > w/O0 or O1.
> 
> It seems that (t[2]-t[1])/UCLOCKS_PER_SEC _is_ 0 when you compile with
> O2 or O3. You are using integer arithmetics, so if the time between 
> t[1] and t[2] is less than one second, the difference of t[1] and t[2] 
...

please take a look at his code:

  clock_t t[2];

with t[2] he is addressing the third element of a 2 element array. even
though dereferencing one past the end of the array is fine, that value
can be anything.

-- 
   Sinan
 
*******************************************************************
 A. Sinan Unur                                WWWWWW
                                              |--O+O
 mailto:sinan DOT unur AT cornell DOT edu                C   ^ 
 http://www.people.cornell.edu/pages/asu1/     \  ~/ 

Unsolicited e-mail is _not_ welcome, and will be billed for.
*******************************************************************

- Raw text -


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