🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #5967

compiled code dumps core

#5967
From: Dean S. Messing
Date: Wed, 15 Jan 1997 00:00
84 lines
2669 bytes
Friends, 

I believe I have discovered a bug in the the gcc compiler.
Here is the pertinent information on my system.

gcc -v gives:

Reading specs from /usr+/gnu/lib/gcc-lib/sparc-sun-solaris2.5/2.7.2.1/specs
gcc version 2.7.2.1

uname -a gives:

SunOS cortex 5.5 Generic sun4m sparc SUNW,SPARCstation-20

In building the compiler I ran configure with no flags other than
`--prefix=/usr+/gnu'

Here is a tiny piece of code to tickle the bug:

       int INF[]	= {0x7ff00000, 0x0};		/* IEEE infinity.  */
       
       main()
       {
         double f;
         f = *(double *)INF;
         printf("f = %lf\n", f);
         return 0;
       }      

I named the above file `oops.c'
Here is a `typescript' to demonstrate the bug.

     Script started on Wed Jan 15 18:41:02 1997
     1:cortex=>gcc oops.c
     2:cortex=>a.out
     Bus Error(coredump)
     3:cortex=>^D

     script done on Wed Jan 15 18:41:09 1997

`gdb' indicates that the failure occurs at the assignment
to `f' on the 2nd line of the main body.
The data I load into INF is irrelevant.  Any legal `double' bit-pattern
causes the same failure.

If I compile with the "-traditional" flag then I get the
correct result:

     Script started on Wed Jan 15 18:45:23 1997
     1:cortex=>gcc -traditional oops.c
     2:cortex=>a.out
     f = Inf
     3:cortex=>^D
     
     script done on Wed Jan 15 18:45:50 1997

Furthermore each of the following versions work correctly
with or without the "-traditional" flag.

       int INF[]	= {0x7ff00000, 0x0};		/* IEEE infinity.  */
       
       main()
       {
         double *f;
         f = (double *)INF;
         printf("*f = %lf\n", *f);
         return 0;
       }      

and

       int INF[]	= {0x7ff00000, 0x0};		/* IEEE infinity. */

       main()
       {
         printf("*(double *)INF = %lf\n", *(double *)INF);
         return 0;
       }       

                                            Dean S. Messing
                                            Digital Video Research
                                            Sharp Laboratories of America
                                    E-Mail: deanm@sharplabs.com
Technical Details
Message-ID: <199701160258.SAA03305@cortex>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113d02,1b0cb93b1c507fb3,start
X-Google-Attributes: gid113d02,public
From: "Dean S. Messing" <deanm@sharplabs.com>
Subject: compiled code dumps core
Date: 1997/01/15
Message-ID: <199701160258.SAA03305@cortex>
X-Deja-AN: 210355059
sender: bug-gcc-request@prep.ai.mit.edu
x-gateway: relay3.UU.NET from bug-gcc to gnu.gcc.bug; Wed, 15 Jan 1997 23:48:39 EST
newsgroups: gnu.gcc.bug