This is the mail archive of the
mailing list for the GCC project.
Re: C++ PATCH: Disallow floating-point literals in integral-constantexpressions
- From: Ranjit Mathew <rmathew at gmail dot com>
- To: mark at codesourcery dot com
- Cc: libstdc++ at gcc dot gnu dot org, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 01 Feb 2005 11:30:29 +0530
- Subject: Re: C++ PATCH: Disallow floating-point literals in integral-constantexpressions
- References: <200502010102.j1112IsD021436@sethra.codesourcery.com>
Mark Mitchell wrote:
> The standard says that floating-point literals are only allowed in
> integral constant expressions if they are immediately cast to an
> integral or enumeration type. When I implemented checks for integral
> constant-expressions, I failed to check this case. Remedied with the
> attached patch.
> The standard library fell afound of this rule in std_limits.h; that's
> now fixed too.
> Tested on x86_64-unknown-linux-gnu, applied on the mainline.
This seems to break libjava on i686-pc-linux-gnu:
./java/util/Hashtable.h:53: error: floating-point literal cannot appear in a con
The relevant line from
static const jfloat DEFAULT_LOAD_FACTOR = 0x1.800000p-1f;
That does look like a floating-point literal, doesn't it?
(jfloat is __java_float and is defined to be a REAL_TYPE
The above was generated by gjavah from the corresponding
Java code in java.util.Hashtable:
private static final float DEFAULT_LOAD_FACTOR = 0.75f;
Ranjit Mathew Email: rmathew AT gmail DOT com
Bangalore, INDIA. Web: http://ranjitmathew.hostingzero.com/