While producing a MCVE for this problem I stumbled upon, I've found the following discrepancy between compilers:
Consider the following code :
// constexpr int f(); // 1
constexpr int g() {
constexpr int f(); // 2
return f();
}
constexpr int f() {
return 42;
}
int main() {
constexpr int i = g();
return i;
}
This code compiles on Clang 3.8.0, but fails on GCC 6.1.0 with:
error: 'constexpr int f()' used before its definition
Commenting out // 2
and uncommenting // 1
works on both compilers.
Interestingly, moving f
's definition in place of // 1
compiles, but triggers a warning at // 2
:
warning: inline function 'constexpr int f()' used but never defined
Which compiler is right ?