[gnu.gcc.bug] bug in casting double/float constants

drh@notecnirp.Princeton.EDU (Dave Hanson) (02/01/89)

[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.