Port-vax archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

One more oddity with gcc and vax floats...



Hi,

this is on:
NetBSD nbvax.tethuvudet.se 11.0_RC4 NetBSD 11.0_RC4 (GENERIC) #0: Tue May 12 04:23:51 UTC 2026

I just noticed another odd behaviour with vax floating point; See this small program:

-------
#include <stdio.h>
#include <math.h>

#pragma STDC FP_CONTRACT off

int
main()
{
	double d;

	d = __builtin_huge_val();
	d *= 2.0;

	printf("%f\n", d);
}
-------


The double get set to the largest available D-float, then it multiplies it with 2 (which should get an overflow signal). But;

nbvax:/home/ragge >cc y.c && ./a.out
Floating exception (core dumped)
nbvax:/home/ragge >cc -O2 y.c && ./a.out
170141183460469229370504062281061498880.000000


Looking at the assembler when optimized the D-float get

	subl2 $4,%sp
	movd $0d-Inf,-(%sp)
	pushab .LC0
	calls $3,printf


Not only that gcc contracts the expression (which it shouldn't), it moves 0d-Inf as argument (which is something I've never seen before; and Inf do not exist on vax)

This is just one more problem with non-IEEE floating point. Since this is a battle that cannot be won maybe I should put the dust of the "Emulate IEEE floating point" stuff I once worked on. Must read up on the IEEE 754 standard first though.

-- R




Home | Main Index | Thread Index | Old Index