[Info-vax] OTS$CVT_FLOAT_T_X broken with quiet NaN on Itanium
Craig A. Berry
craigberry at nospam.mac.com
Sat Sep 20 17:19:28 EDT 2014
The following little program illustrates that promotion of a double
containing a quiet NaN to a long double produces an incorrect result
(but only on Itanium -- Alpha is fine):
$ type checknan2.c
#include <stdio.h>
#include <math.h>
#include <float.h>
int main() {
double d;
long double ld;
d = DBL_QNAN;
printf(" double NaN is %g\n", d);
ld = d;
printf(" double NaN assigned to long double is %Lg\n", ld);
ld = (long double)d;
printf("double NaN assigned to long double with cast is %Lg\n", ld);
if (isnan(d))
ld = LDBL_QNAN;
printf(" long double NaN set explicitly is %Lg\n", ld);
}
$ cc/float=ieee/ieee=denorm checknan2
$ link checknan2
$ r checknan2
double NaN is NaNQ
double NaN assigned to long double is -Infinity
double NaN assigned to long double with cast is -Infinity
long double NaN set explicitly is NaNQ
$ cc/version
HP C V7.3-020 on OpenVMS IA64 V8.4
Those two instances of "-Infinity" should actually be NaNQ, and on Alpha
they are. Infinities and signalling NaNs are fine, but quiet NaNs are
broken on Itanium.
A compiler listing shows that the conversion from double to long double
is done with OTS$CVT_FLOAT_T_X on both Alpha and Itanium. I don't know
why the implementations would be different as they should just be
pushing around well-known bit patterns. I was surprised to see the
function call on Itanium as I thought it had native instructions for
these things, but maybe that's only for arithmetic operations and not
for conversions.
Just posting here in case anyone else trips over the same thing and does
a search. Hardly seems worth reporting to HP after Neil Rieck's recent
experience.
More information about the Info-vax
mailing list