g++ problem with float/double on Solaris 2.8 (resend)

Paul Heffner Paul.Heffner@xilinx.com
Mon Apr 8 14:48:00 GMT 2002


>Submitter-Id:  net
>Originator: Paul Heffner
>Organization:  Xilinx Technical Services
>Confidential:  no
SEND-PR: Leave "Confidential" as "no"; all GCC PRs are public.
>Synopsis:      g++ does not generate correct code for float and double
types
>Severity:      serious
SEND-PR: critical     GCC is completely not operational; no work-around
known.
SEND-PR: serious      GCC is not working properly; a work-around is
possible.
SEND-PR: non-critical Report indicates minor problem.
>Priority:      medium
SEND-PR: medium       The problem should be solved in the next release.
SEND-PR: low          The problem should be solve in a future release.
>Category:      c++
>Class:         wrong-code
SEND-PR: doc-bug          The documentation is incorrect.
SEND-PR: accepts-illegal  GCC fails to reject erroneous code.
SEND-PR: rejects-legal    GCC gives an error message for correct code.
SEND-PR: wrong-code       The machine code generated by gcc is
incorrect.
SEND-PR: ice-on-legal-code   GCC gives an Internal Compiler Error (ICE)
SEND-PR:                     for correct code
SEND-PR: ice-on-illegal-code GCC gives an ICE instead of reporting an
error
SEND-PR: pessimizes-code     GCC misses an important optimization
opportunity
SEND-PR: sw-bug              Software bug of some other class than above

SEND-PR: change-request      A feature in GCC is missing.
SEND-PR: support             I need help with gcc.
>Release:       3.0.4
>Environment:
System: SunOS dynamo 5.8 Generic_108528-12 sun4u sparc SUNW,Ultra-5_10
Architecture: sun4

        <machine, os, target, libraries (multiple lines)>
host: sparc-sun-solaris2.8
build: sparc-sun-solaris2.8
target: sparc-sun-solaris2.8
configured with: /u2/src/gcc-3.0.4/configure --prefix=/tools/gcc/3.0.4
--enable-
languages=c,c++ --enable-threads=posix --verbose --with-gnu-ld
--with-ld=/tools/
gcc/binutils/bin/ld --with-gnu-as --with-as=/tools/gcc/binutils/bin/as
>Description:
        Programs using float or double types have incorrect code
generated
        for all operations. I compiled with gcc 2.95.3 and Sun forte for

the
        first stage compile with identical results. Likewise I varied
using
        binutils and Sun's /usr/ccs/bin for the assembler and linker
with
        identical results.
>How-To-Repeat:
        Attatched is a very small c++ program which exposes the problem
nicely.
        When compiled with 3.0.4, the output of the program looks like:
Size of float is: 1.06034e-313
fpvar=0x3fb47ae1
Size of double is: 1.90914e-313
dfpvar=0x3ff1c28f

On any other platform the output looks like:
Size of float is: 4
fpvar=0.08
Size of double is: 8
dfpvar=1.11

The compilation command was: g++ -R/usr/local/lib -o testf testf.cc

The 'configured with' above was the last attempted one. I tried it with
the Sun bintools
to no advantage.

>Fix:
        None I know of other than using 2.95.3 g++ or Forte.
-------------- next part --------------
#include <iostream>
using namespace std;

int main(int argc,char *argv[])
{	float	fpvar=0.08;
	double	dfpvar=1.11;
	cout << "Size of float is: " << sizeof(float) << endl;	
	cout << "fpvar=" << fpvar << endl;	
	cout << "Size of double is: " << sizeof(double) << endl;	
	cout << "dfpvar=" << dfpvar << endl;	
	exit(0);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testf.ii.bz2
Type: application/octet-stream
Size: 61883 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20020408/11a9e6d6/attachment.obj>


More information about the Gcc-bugs mailing list