constexpr non-static member function with non-constexpr constructor (gcc,clang differ)
问题 For this code: struct S { S(int m): m(m) {} constexpr int f() const { return m; } int m; }; int main() { S s(1); } it is compiled with no warnings or errors by clang 3.6, 3.7 and 3.8 with -std=c++14 . But in g++ 5.x the following errors occur: main.cpp:4:19: error: enclosing class of constexpr non-static member function 'int S::f() const' is not a literal type constexpr int f() const { return m; } ^ main.cpp:1:8: note: 'S' is not literal because: struct S ^ main.cpp:1:8: note: 'S' is not an