🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2217

bug in casting double/float constants

#2217
From: Dave Hanson
Date: Wed, 01 Feb 1989 13:53
34 lines
1326 bytes
[16] cat bug.c
double x = (float).3;
main() {}
[17] gcc -v bug.c
gcc version 1.31
 /usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dvax -Dunix bug.c /tmp/cc027173.cpp
GNU CPP version 1.31
 /usr/local/lib/gcc-cc1 /tmp/cc027173.cpp -quiet -dumpbase bug.c -version -o /tmp/cc027173.s
GNU C version 1.31 (vax) compiled by GNU C version 1.31.
 /usr/local/lib/gcc-as /tmp/cc027173.s -o bug.o
 ld /lib/crt0.o bug.o /usr/local/lib/gcc-gnulib -lc
[18] cat bug.s
#NO_APP
.globl _x
.data
	.align 2
_x:
	.dfloat 0d3.00000000000000000000e-01
[19]  adb
main+2:b
:r
a.out: running
breakpoint	_main+2:	ret
x/X
_x:
_x:		99993f99

_x+4:		999a9999
$q

the second longword of x at _x+4 should be 0.
that is, the double constant is truncated to float
by the cast, then widened back to double by
the implicit cast in the initialization.
Technical Details
Message-ID: <14562@princeton.Princeton.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!rutgers!njin!princeton!notecnirp!drh

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!rutgers!njin!princeton!notecnirp!drh
From: drh@notecnirp.Princeton.EDU (Dave Hanson)
Newsgroups: gnu.gcc.bug
Subject: bug in casting double/float constants
Message-ID: <14562@princeton.Princeton.EDU>
Date: 1 Feb 89 13:53:53 GMT
Sender: news@princeton.Princeton.EDU
Reply-To: drh@princeton.Princeton.EDU (Dave Hanson)
Distribution: gnu
Organization: Dept. of Computer Science, Princeton University
Lines: 34