http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57979
Bug ID: 57979 Summary: G++ accepts constant expression defined using floating point glvalue Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jogojapan at gmail dot com The following code is accepted and compiled without error by G++: int main() { const float f1 = 0.0; constexpr float f2 = f1; return 0; } Note that the declaration of f2 as constexpr requires f1 to be a constant expression, which it isn't, according to ยง5.19/2: ====(QUOTE)======== A condition-expression is a core constant expression unless it involves [...] [..9th item..] - an lvalue-to-rvalue conversion (4.1) unless it is applied to [...] a glvalue of integral or enumeration type that refers to a non-volatile const object with a preceding initialization, initialized with a constant expresion, or [...] ====(ENDQUOTE)==== So if f1 had been declared as const int, the code would be acceptable, but there is no such exception for floating point (or any other non-integral or non-enum type). Tested with a 20130708 snapshot checkout from the master branch of the git-mirror of the repository. (I'll test with a more recent version soon.)