https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70449
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org, | |jason at gcc dot gnu.org --- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The reason for the UNKNOWN_LOCATION is that in the testcase we try to instantiate_decl the function being currently parsed, and do there 22017 input_location 22018 = DECL_STRUCT_FUNCTION (code_pattern)->function_end_locus; but because we are in the middle of parsing that template, we haven't parsed the closing } of the function template yet, so function_end_locus is unset. That is also the reason for the bogus warning, the so far parsed statements of the function template don't contain any return statements. What does C++11/14 say about this? clang++ 3.8 on this testcase warns: warning: inline function 'f<0>' is not defined [-Wundefined-inline] and if I add additional constexpr int c = f<0> (); after the template, it errors on it: error: expression is not an integral constant expression Both the clang diagnostics look really weird, I hope this really is invalid in C++, can't see what the compiler could do there, because it needs the function to be already parsed to use proper enumerators. If I try constexpr int f () { enum E { a = f () }; return 0; } instead, then clang++ diagnostics is similarly weird, but g++ reports a nice pr70449-3.C: In function ‘constexpr int f()’: pr70449-3.C:3:18: error: ‘constexpr int f()’ called in a constant expression before its definition is complete enum E { a = f () }; ~~^~ pr70449-3.C:3:19: error: enumerator value for ‘a’ is not an integer constant enum E { a = f () }; ^ error. So I think it would be best if we could emit the same diagnostics even with templates.