Mycroft Holmes
2009-12-09 08:15:25 UTC
Hi,
I was pretty surprised when VC2008 happily compiled the code below
(even with language extensions disabled): I noticed that Comeau
rejects it in strict mode, but accepts in relaxed mode.
I was convinced it's illegal to have floating-point intermediate
results when computing a static constant IIRC, the motivation was that
floating point operations, such as rounding, may depend on a state of
the processor which is available only at runtime.
Do I remember correctly? Is there any plan to change it in the
standard?
template <int N>
struct test
{
static const int value = int(N * 1.2);
};
int main()
{
return test<7>::value;
}
I was pretty surprised when VC2008 happily compiled the code below
(even with language extensions disabled): I noticed that Comeau
rejects it in strict mode, but accepts in relaxed mode.
I was convinced it's illegal to have floating-point intermediate
results when computing a static constant IIRC, the motivation was that
floating point operations, such as rounding, may depend on a state of
the processor which is available only at runtime.
Do I remember correctly? Is there any plan to change it in the
standard?
template <int N>
struct test
{
static const int value = int(N * 1.2);
};
int main()
{
return test<7>::value;
}