The C++ program below compiles with GCC trunk:
template <typename T>
struct Foo
{
constexpr void test();
};
void not_constexpr() {}
template <>
constexpr void Foo<int>::test() { }
template <>
void Foo<float>::test() { not_constexpr(); }
int main() {}
But fails with Clang and MSVC. The error message is:
<source>:13:28: error: non-constexpr declaration of 'test' follows constexpr declaration
13 | void Foo<float>::test() { not_constexpr(); }
| ^
<source>:4:18: note: previous declaration is here
4 | constexpr void test();
This can be seen on Compiler Explorer here. Which compiler is correct?