http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59676

            Bug ID: 59676
           Summary: Non-integral glvalues accepted in constant expressions
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ville.voutilainen at gmail dot com

constexpr int foo(float f) {return int(f);} 

int main() 
{ 
    const float x = 0.5; 
    static_assert(x > 0.1, "all good"); // #1
    constexpr int i = foo(x); // #2
}

gcc accepts this, clang doesn't accept either #1 or #2.
[expr.const]/2 bullet 7, sub-bullet 1 says
"a non-volatile glvalue of integral or enumeration type that refers to a
non-volatile const object with
a preceding initialization, initialized with a constant expression".
It looks to me as if we have a non-volatile glvalue of a non-integral
type, so x and (x>0.1) are not constant expressions, and static_assert
and the initialization of i shouldn't allow using x.

Reply via email to