C++ PATCH: Disallow floating-point literals in integral-constant expressions
Mark Mitchell
mark@codesourcery.com
Tue Feb 1 06:21:00 GMT 2005
Ranjit Mathew wrote:
>>> static const jfloat DEFAULT_LOAD_FACTOR = 0x1.800000p-1f;
>>
>>Ugh. That's invalid C++.
>
>
> Then that should have been a different error, no? :-)
> (But I'm curious - and an ignoramus - why is that invalid?)
See this morning's discussion on the GCC mailing list.
The code generate by gjavah is invalid on two counts: (1) you can't have
an in-class initialization a static data member of non-integral type,
and (2) even for a static data member with integral type, the
initializer has to be an integral constant expression, which a
floating-point literal is not.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304
More information about the Libstdc++
mailing list