www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/12/05/23:15:05

Xref: news-dnh.mv.net comp.os.msdos.djgpp:3613
Path: news-dnh.mv.net!mv!news.sprintlink.net!news.texas.net!newshost.comco.com!news.tamu.edu!xenon.brooks.af.mil!natinst.com!cs.utexas.edu!swrinde!newsfeed.internetmci.com!in2.uu.net!fdn.fr!jussieu.fr!univ-lyon1.fr!in2p3.fr!swidir.switch.ch!serra.unipi.it!gip
From: gip AT firefox DOT ino DOT it (GianPiero Puccioni)
Newsgroups: comp.os.msdos.djgpp
Subject: Possible Bug in V2 ( -O and libm)
Date: 4 Dec 1995 15:12:58 GMT
Organization: Istituto Nazionale di Ottica-Florence-ITALY
Lines: 67
Nntp-Posting-Host: a730.ino.it
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Dj-Gateway: from newsgroup comp.os.msdos.djgpp

Hi,

  I think I found a problem with the optimizer of V2b3. I was playing around
with Paranoia.c (it was with the test programs) and when I optimized it it
reported a wrong "radix", (i.e. 4096 instead of 2). I reduced the problem
to this bit:
---------------------------------------------------
#include <stdio.h>
#include <math.h>

double Zero = 0.0;
double One = 1.0;
double MinusOne = -1.0;
double W;
double Y;
double Z;

int main(void)
{
	W = One;
	do  {
		W = W + W;
		Y = W + One;
		Z = Y - W;
                printf("W=%f Y=%f Z=%f\n", W,Y,Z);
		Y = Z - One;
		} while (MinusOne + fabs(Y) < Zero);
	/*.. now W is just big enough that |((W+1)-W)-1| >= 1 ...*/
    }
---------------------------------------------------

I added the "printf" to see what was happening and...
when compiled with no optimization it printed:

[snip]
W=2251799813685248.000000 Y=2251799813685249.000000 Z=1.000000
W=4503599627370496.000000 Y=4503599627370497.000000 Z=1.000000
W=9007199254740992.000000 Y=9007199254740992.000000 Z=0.000000

while when optimized (gcc -O)
[snip]
W=4503599627370496.000000 Y=4503599627370497.000000 Z=1.000000
W=9007199254740992.000000 Y=9007199254740992.000000 Z=1.000000
W=18014398509481984.000000 Y=18014398509481984.000000 Z=1.000000
[snip]
W=9223372036854775808.000000 Y=9223372036854775808.000000 Z=1.000000
W=18446744073709551616.000000 Y=18446744073709551616.000000 Z=0.000000

it seems that (Y-W) gives 1.0 even when Y and W are the same.
I tried version 1.12m2 and it does exactly the same so I don't know if
it's a bug or I did something wrong........


Another possible problem: pow2 seems to be missing from the libraries
(but I don't know if the beta libraries were meant to be complete).

My setup is P90 16Mb DOS6.2 QEMM7.5 (but I was using CWSDPMI).  
Ciao,

       GianPiero 

--
****************************************************************************
*  Istituto Nazionale di Ottica                        GianPiero Puccioni  *
*  Largo E.Fermi 6                           E-Mail :  gip AT firefox DOT ino DOT it  *
*  I-50125  Firenze - ITALY             c=it;a=garr;p=ino;o=firefox;s=gip  *
****************************************************************************

- Raw text -


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