This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: C++ PATCH: Disallow floating-point literals in integral-constant expressions
On Mon, 31 Jan 2005 22:08:38 -0800, Mark Mitchell <mark@codesourcery.com> wrote:
> Ranjit Mathew wrote:
> > 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
> > stant-expression
> >
> > The relevant line from
> > $BUILD_DIR/i686-pc-linux-gnu/libjava/java/util/Hashtable.h is:
> >
> > 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?)
> However, we can't have a broken Java compiler.
>
> I'll take a quick look at fixing gjavah, and, failing that, disable the
> new error temporarily.
The methods should be (I'm not 100% certain),
jni_print_float/double in gcc/java/gjavah.c.
Thanks,
Ranjit.
--
Ranjit Mathew Email: rmathew AT gmail DOT com
Bangalore, INDIA. Web: http://ranjitmathew.hostingzero.com/