Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: gwesp@wst.edvz.sbg.ac.at (Wesp Gerhard)
Subject: Re: OSF/1 1.3 cc -O Bug!
Date: Tue, 22 Feb 1994 16:31:56 GMT	[thread overview]
Message-ID: <CLMwL8.9uw@wst.edvz.sbg.ac.at> (raw)
In-Reply-To: 2kbb1p$630@paperboy.gsfc.nasa.gov

In <2kbb1p$630@paperboy.gsfc.nasa.gov>, Frederick (Rick) A Niles (niles@axp745.gsfc.nasa.gov) wrote:

> How's this for a bug:
> The following crashes for 'cc -O' and not for 'cc'
> under OSF/1 1.3 and NOT under OSF/1 1.2:


> int DATA_is_illegal(f)
> float f;
> {
>         unsigned int *num;

>         num = (unsigned int *) &f;

>         if (*num == 0x7FFFFFFF) {
>                 return(1);
>         }


>         return(0);
> }


> Just a wondering what ya think.....
> Give it a try....
> 		Rick Niles
> 			niles@axp745.gsfc.nasa.gov

The quality of DEC's software products is really amazing...
I simplified the example a little bit:

------ crash.c: --------
int i(double x)
{
  int *p;
  p= &x;
  return *p;
}
------- EOF ------------

First of all, please note that that piece of code may even have
an application: If int and double have the same storage size, 
this should just 'typecast' the argument x to an int, yielding the internal 
representation of the double. You could then use the int to extract
the fields of the double (sign, mantissa, exponent).

However, a compilation attempt had the following result:
% cc -O crash.c
/usr/lib/cmplrs/cc/cfe: Warning: crash.c, line 4: Incompatible pointer type 
assignment
   p= &x;
 ---^
Fatal error in: /usr/lib/cmplrs/cc/ugen Segmentation fault - core dumped 

Our OS and compiler version:
% uname -a
OSF1 picard V1.3 112 alpha
% cc -V
cc  (cc)
        The DEC OSF/1 AXP Compiler Driver 3.11
[many $RCSfile: lines deleted]

 cc without "-O" also worked for me. I can't verify if it works on OSF1 1.2,
because I don't have it. "c89 -O" also core dumps (you must explicitly type-
cast &x to (int *) in order to make c89 compile the code), because it
invokes the same "ugen".

 I don't know if the bug (YES, this is a *BUG*) resides in the OS or the
compiler, but I hope the people at DEC (who are reading this, right?) will
*IMMEDIATELY* find that out and fix it. 

Greetings,
-Gerhard


  reply	other threads:[~1994-02-22 16:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-02-21 22:02 OSF/1 1.3 cc -O Bug! Frederick (Rick) A Niles
1994-02-22 16:31 ` Wesp Gerhard [this message]
1994-02-22 19:19   ` Rick Murphy
1994-02-23 11:47     ` Wesp Gerhard
1994-02-25 20:55       ` Rick Murphy
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox