From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,318ffa5ce8258c67 X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-02-22 08:31:56 PST Newsgroups: comp.unix.osf.osf1 Path: gmd.de!newsserver.jvnc.net!howland.reston.ans.net!cs.utexas.edu!uunet!news.univie.ac.at!edvz.sbg.ac.at!gwesp From: gwesp@wst.edvz.sbg.ac.at (Wesp Gerhard) Subject: Re: OSF/1 1.3 cc -O Bug! Message-ID: Sender: news@wst.edvz.sbg.ac.at (USENET News System) Organization: University of Salzburg / Austria X-Newsreader: TIN [version 1.2 PL1] References: <2kbb1p$630@paperboy.gsfc.nasa.gov> Date: Tue, 22 Feb 1994 16:31:56 GMT 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