https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87372
Bug ID: 87372 Summary: __PRETTY_FUNCTION__ not constexpr in gcc trunk on compiler explorer Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: eric-bugs at omnifarious dot org Target Milestone: --- This code will not compile with gcc trunk on compiler explorer. But it works with gcc 8.2 on that some site. I'm worried this is a regression in current C++ development. constexpr int zstrlen(char const *s) { int i = 0; while (s[i]) ++i; return i; } int joe() { constexpr char const * const foo = __PRETTY_FUNCTION__; constexpr int foolen = zstrlen(foo); return foolen; } It fails to work because __PRETTY_FUNCTION__ isn't constexpr in gcc trunk. I get this error message: <source>: In function 'int joe()': <source>:11:35: in 'constexpr' expansion of 'zstrlen(((const char*)foo))' <source>:11:39: error: the value of '__PRETTY_FUNCTION__' is not usable in a constant expression 11 | constexpr int foolen = zstrlen(foo); | ^ <source>:10:40: note: '__PRETTY_FUNCTION__' was not declared 'constexpr' 10 | constexpr char const * const foo = __PRETTY_FUNCTION__; | ^~~~~~~~~~~~~~~~~~~ Compiler returned: 1 Here is a link: https://godbolt.org/z/8IdAae