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

            Bug ID: 112555
           Summary: NTTP of cv-qualified pointer type fails to mangle in
                    those qualifiers
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arthur.j.odwyer at gmail dot com
  Target Milestone: ---

// https://godbolt.org/z/EGv36xzY6
template<auto V> struct A;

template<class T> void foo();

int i;
int main() {
    foo<A<(int*)nullptr>>();
    foo<A<(const int*)nullptr>>();
    foo<A<(int*)&i>>();
    foo<A<(const int*)&i>>();
}

Clang mangles each call to `foo` differently:
  callq _Z3fooI1AILPi0EEEvv@PLT
  callq _Z3fooI1AILPKi0EEEvv@PLT
  callq _Z3fooI1AIXadL_Z1iEEEEvv@PLT
  callq _Z3fooI1AIXcvPKiadL_Z1iEEEEvv@PLT
GCC mangles the `int*` and `const int*` versions differently for nullptr, but
identically for `&i`. I think this is a GCC bug.
  call _Z3fooI1AILPi0EEEvv
  call _Z3fooI1AILPKi0EEEvv
  call _Z3fooI1AIXadL_Z1iEEEEvv
  call _Z3fooI1AIXadL_Z1iEEEEvv

NVC++ (EDG front-end) matches GCC, not Clang.
MSVC matches Clang, in that the `int*` and `const int*` versions are mangled
distinctly (but using MSVC ABI's mangling conventions of course).

Bug #107222 might be related but seems to be the opposite problem, if anything?

Reply via email to