https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120896

            Bug ID: 120896
           Summary: __PRETTY_FUNCTION__ incorrect behavior (depends on
                    instanciation order)
           Product: gcc
           Version: 15.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kelbonage at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/7zn8Echa5


```cpp

#include <print>

template <typename T = int>
struct S
{};

template <typename T>
constexpr const char* n()
{
    static auto name = __PRETTY_FUNCTION__;
    return name;
}

int main()
{
    std::println("{}", n<S<>>());
    std::println("{}", n<S<int>>());
}

```

Output:
constexpr const char* n() [with T = S<>]
constexpr const char* n() [with T = S<>]

But if line order changed:

   std::println("{}", n<S<int>>());
   std::println("{}", n<S<>>());

Output:

constexpr const char* n() [with T = S<int>]
constexpr const char* n() [with T = S<int>]

Reply via email to