Squelch HOST_FLOAT_WORDS_BIG_ENDIAN
Zack Weinberg
zack@codesourcery.com
Thu Mar 13 18:55:00 GMT 2003
Richard Henderson <rth@redhat.com> writes:
> On Wed, Mar 12, 2003 at 01:10:04AM -0800, Zack Weinberg wrote:
>> + /* C99 doesn't allow use of hexadecimal floating constants
>> + to represent infinities and NaN. Bleh. */
>> if (! java_float_finite (fnum))
>
> C99 doesn't, but GCC does. See __builtin_inf & __builtin_nan.
> These builtins are intended to be usable anywhere regular fp
> constants are. If that isn't the case, we have a bug.
It appears that we do have a bug.
float qnan = __builtin_nanf(0);
float snan = __builtin_nansf(0);
$ ./cc1 -quiet -version test.c
GNU C version 3.4 20030312 (experimental) (i686-pc-linux-gnu)
compiled by GNU C version 3.4 20030312 (experimental).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64616
test.c:1: error: initializer element is not constant
test.c:2: error: initializer element is not constant
Or, for a direct analog to what gcjh might generate:
class Double {
public:
static const double NaN = __builtin_nan(0);
};
$ ./cc1plus test.cc
test.cc:3: error: `double __builtin_nan(const char*)' cannot appear in a
constant-expression
test.cc:3: error: a function call cannot appear in a constant-expression
Incidentally, why is the argument to __builtin_nan a string constant?
Wouldn't it be simpler to make it a number?
(And the syntax that I would have chosen for this is something like
0x1.0p+INF
0x1.xxxxxxp+NAN (QNAN, SNAN)
which would require less fragile special-casing of builtin functions, etc.)
zw
More information about the Java
mailing list