This is the mail archive of the
mailing list for the GCC project.
Re: C++ PATCH: Disallow floating-point literals in integral-constantexpressions
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.