This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]