------- Comment #28 from jason at gcc dot gnu dot org  2010-08-31 17:26 -------
(In reply to comment #18)
> The optimization question in Comment #11 was answered incorrectly.
> The C++ standard in fact requires that Y be initialized before the constructor
> is run; see [basic.start.init].

I disagree.  In C++03, [basic.start.init] says

Objects of POD types (3.9) with static storage duration initialized with
constant expressions (5.19) shall be initialized before any dynamic
initialization takes place.

5.19 [expr.const] says

An arithmetic constant expression shall satisfy the requirements for an
integral constant expression, except that
  — floating literals need not be cast to integral or enumeration type, and
  — conversions to floating point types are permitted.

Note that this does not allow an arithmetic constant expression to involve
const variables of floating point type, so "X + 2.0" is not an arithmetic
constant expression, so Y is not required to have static initialization.  But
it is allowed to, as explained in comment #14.

I think this distinction is not observable in C++03.  But with C++0x constexpr
it is; declaring Y as constexpr would be ill-formed unless X is also declared



Reply via email to