https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64356
Bug ID: 64356 Summary: Some constexpr expressions not recognized as constexpr Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sneves at dei dot uc.pt Consider the following snippet: template<size_t N> constexpr uint64_t f(const char (&x)[N]) { uint64_t s = 0; #if defined(FAILS) for(uint64_t c : x) s += c; #else for(size_t i = 0; i < N; ++i) s += x[i]; #endif return s; } template<size_t N> constexpr uint64_t g(const char (&x)[N]) { char y[N] = {0}; for(size_t i = 0; i < N; ++i) y[i] = x[i]; #if defined(FAILS) return f(y); #else return f(x); #endif } constexpr auto x = g(__DATE__); When FAILS is defined, GCC (trunk, 20141219) refuses to recognize x as a constant expression, while with FAILS undefined it works as expected. Clang accepts both variants.