This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Invalid code in <limits>
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc at gcc dot gnu dot org
- Cc: gdr at integrable-solutions dot net, rth at redhat dot com
- Date: Tue, 28 Jan 2003 21:34:42 -0800
- Subject: Invalid code in <limits>
- Reply-to: mark at codesourcery dot com
The C++ standard library <limits> code contains this pattern:
static const bool has_infinity
= __builtin_huge_valf () / 2 == __builtin_huge_valf ();
in several places.
Syntactically, a function call cannot appear in a constant-expression,
which is what is required for a static member initializer.
I've got patches to correctly diagnose this error, and they're
tripping on this code in the standard library.
Theoretically, we could try to exempt built-ins, but it is going to
get very complicated to try to get that right in the presence of
templates/dependent names/two-phase name lookup. We really don't want
to go there.
One way to fix this would to be to introduce magic variables as well
as the builtin functions. These magic variables would be defined
like:
static const __builtin_huge_valf_constant = <the value>;
Or maybe have the preprocessor define symbols ala __SIZE_TYPE__ for
this purpose?
Or maybe magic keywords?
Thoughts?
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com