Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Mar 1998 09:44:04 -0800 (PST)
From:      Tom Bartol <bartol@salk.edu>
To:        freebsd-current@FreeBSD.ORG
Subject:   gcc bug in -current!!!
Message-ID:  <Pine.BSF.3.96.980324090529.2860C-100000@dale.salk.edu>

next in thread | raw e-mail | index | archive | help

Hi all,

I just found and narrowed down the following bug in gcc in -current after
a cvsup and make world as of Mon Mar 23 12:14:55 PST.  This bug appears to
have crept in sometime between then and Feb 14.  Included below is a small
program which demonstrates the bug along with output from the program
compiled on yesterday's -current and Feb. 14 -current. It appears to be a
bug with the handling of the sign bit in static unsigned int quantities. 
Note the incorrect sign of the double-precision values in the printout and
how the sign changes anomalously when  cc  and then  cc -O  is used for
the compilation on yesterday's -current.  I thought I should report this
right away since compiler bugs can have nasty effects especially when you
use it to rebuild your whole system :-(

Thanks,

Tom


Here is the program:


#include <stdio.h>

main() 
{
  double d1,d2,d3,d4;
  static unsigned int c1 = 0x80000000;
  unsigned int c2 = 0x80000000;
  static unsigned int c3 = 0x40000000;
  unsigned int c4 = 0x40000000;
  
  d1=c1;
  d2=c2;
  d3=c3;
  d4=c4;

  printf("c1 = %x   c2 = %x\n",c1,c2);
  printf("d1 = %12.9e   d2 = %12.9e\n",d1,d2);
  printf("\nc3 = %x   c4 = %x\n",c3,c4);
  printf("d3 = %12.9e   d4 = %12.9e\n",d3,d4);

  exit(0);
}


Here is the output after compiling on yesterday's -current using cc with
no compiler flags: 

c1 = 80000000   c2 = 80000000
d1 = -2.147483648e+09   d2 = -2.147483648e+09

c3 = 40000000   c4 = 40000000
d3 = 1.073741824e+09   d4 = 1.073741824e+09



Here is the output after compiling on a Feb 14 -current using cc with no
compiler flags:

c1 = 80000000   c2 = 80000000
d1 = 2.147483648e+09   d2 = 2.147483648e+09

c3 = 40000000   c4 = 40000000
d3 = 1.073741824e+09   d4 = 1.073741824e+09



Here is the output after compiling on a yesterday's -current using cc -O:

c1 = 80000000   c2 = 80000000
d1 = -2.147483648e+09   d2 = 2.147483648e+09

c3 = 40000000   c4 = 40000000
d3 = 1.073741824e+09   d4 = 1.073741824e+09



Here is the output after compiling on a Feb 14 -current using cc -O: 

c1 = 80000000   c2 = 80000000
d1 = 2.147483648e+09   d2 = 2.147483648e+09

c3 = 40000000   c4 = 40000000
d3 = 1.073741824e+09   d4 = 1.073741824e+09



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.980324090529.2860C-100000>