On OpenBSD/luna88k 8.0-beta, the following test compares
a volatile double with the constant used to initialize it.
```
volatile double value = 0x1p128;
int
main(void)
{
return (value == 0x1p128) ? 0 : 9;
}
```
Save this as fp02-overflow.c and run
gcc -O0 fp02-overflow.c -o fp02-overflow
./fp02-overflow
echo $?
The expected exit status is 0.
The value 0x1p128 is finite and exactly representable in
double precision, so the comparison should be true.
However the observed exit status was 9.
The object contains the correct double value, but the generated
comparison uses positive infinity as a single-precision operand.
set %r7,%r0,8<23>
fcmp.sds %r9,%r8,%r7
The first instruction produces 0x7f800000, single-precision positive
infinity, in the source register used by fcmp.sds.
This was observed under nono 1.8.3 emulating an MC88100.
The disk image was assembled from official OpenBSD/luna88k 8.0-beta
snapshot binaries with a BUILDINFO build date of 2026-09-15 (UTC).
The compiler was the supplied native gcc 4.2.1 20070719.
In gnu/gcc/gcc/config/m88k/m88k.c, legitimize_operand() shortens
double constants to single precision without checking that their
values are preserved:
```
if (exponent != 0x7ff /* NaN */
&& l[1] == 0 /* Mantissa fits */
&& ((exponent >> 7) == 0x8
|| (exponent >> 7) == 0x7) /* Exponent fits */
&& (temp = simplify_unary_operation (FLOAT_TRUNCATE, SFmode,
op, mode)) != 0)
return gen_rtx_FLOAT_EXTEND (mode, force_reg (SFmode, temp));
```
In this case, it accepts 0x1p128 even though conversion to
single precision produces infinity.
A suggested fix is to shorten a finite double constant only when
it can be represented exactly in the target single-precision format,
including the sign of zero. Otherwise, keep the operand in double
precision.
dmesg: (on nono emulator emulating LUNA-88K)
---
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.
Copyright (c) 1995-2026 OpenBSD. All rights reserved. https://www.OpenBSD.org
OpenBSD 8.0-beta (GENERIC) #0: Tue Sep 15 18:09:37 JST 2026
[email protected]:/usr/src/sys/arch/luna88k/compile/GENERIC
real mem = 67104768 (63MB)
avail mem = 60502016 (57MB)
random: boothowto does not indicate good seed
mainbus0 at root: OMRON LUNA-88K, 25MHz
cpu0: M88100 rev 0xb, 2 CMMU
cpu0: M88200 (16K) rev 0x9, full Icache
cpu0: M88200 (16K) rev 0x9, full Dcache
clock0 at mainbus0: MK48T02
lcd0 at mainbus0
le0 at mainbus0: address 02:00:01:83:9a:47
le0: 32 receive buffers, 8 transmit buffers
sio0 at mainbus0: 7201a
siotty0 at sio0 channel 0 (console)
ws0 at sio0 channel 1
wskbd0 at ws0 mux 1
wsmouse0 at ws0 mux 0
xp0 at mainbus0: HD647180X I/O processor
fb0 at mainbus0: 1280x1024, 4bpp
wsdisplay0 at fb0 mux 1
wskbd0: connecting to wsdisplay0
wsdisplay0: screen 0 added (std, vt100 emulation)
spc0 at mainbus0
scsibus0 at spc0: 8 targets, initiator 7
cd0 at scsibus0 targ 5 lun 0: <NONO, SCSICD, > removable
sd0 at scsibus0 targ 6 lun 0: <NONO, SCSIHD, >
sd0: 2048MB, 512 bytes/sector, 4194304 sectors
vscsi0 at root
scsibus1 at vscsi0: 256 targets
softraid0 at root
scsibus2 at softraid0: 256 targets
boot device: sd0
root on sd0a (c71ef0b1c4b73dd3.a) swap on sd0b dump on sd0b
WARNING: clock gained 5 days
WARNING: CHECK AND RESET THE DATE!