This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Invalid code in <limits>
Richard Henderson <rth@redhat.com> writes:
| On Wed, Jan 29, 2003 at 12:06:18AM -0800, Mark Mitchell wrote:
| > The bottom line is that there's no need to make the compiler work
| > hard to deal with this stuff; it's easy to make a keyword whose value
| > is "__builtin_huge_valf () / 2 == __builtin_huge_valf ()" or
| > "__builtin_nanf ("") != __builtin_nanf ("")"; you just evaluate that
| > expression in the guts of the compiler where it can do whatever it
| > wants.
|
| Ok, but how about
|
| struct S {
| static const double f = 1.0;
| static const double g = __builtin_huge_valf ();
| };
|
| (or whatever context is hardest for c++)? If either
| works, they should both work.
Technically, the above are invalid constructs, *but* they are (or used
to be) supported by various compilers in different modes. There is no
compelling reason why only integral-expression should be allowed.
Rewrite the above as
struct A {
static const double f;
static const double g;
};
const double A::f = 1.0;
const double A::g = __builtin_huge_valf();
extend with
struct B {
static const char i = static_cast<int>(43);
};
static_cast<> is no different from __builtin_huge_valf().
-- Gaby