https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99013
Bug ID: 99013 Summary: std::source_location::function_name should return same result in constexpr mode and non-constexpr Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hanicka at hanicka dot net Target Milestone: --- Hi found out std::source_location is returning different result in constexpr: ``` #include <source_location> template<auto Object> constexpr std::string_view get_object_name1() { /*constexpr*/ const char * ptr = std::source_location::current().function_name(); return ptr; } template<auto Object> constexpr std::string_view get_object_name2() { constexpr const char * ptr = std::source_location::current().function_name(); return ptr; } void foo() { } ``` when called `get_object_name1<foo>` it returns `constexpr std::string_view get_object_name1() [with auto Object = foo; std::string_view = std::basic_string_view<char>]` but when called `get_object_name2<foo>` it returns `constexpr std::string_view get_object_name2()` the difference is the BUG (missing `[with auto Object = foo; std::string_view = std::basic_string_view<char>]`) error with latest trunk on compiler-explorer.com https://compiler-explorer.com/z/4e8Gd1