Skip to content

[abi][ItaniumMangle] Inconsistent mangling of friend function templates. #110480

Open
@VitaNuo

Description

@VitaNuo

a.cc:

template <class>
concept True = true;

namespace test2 {
  template<typename T> struct A {
    template<typename U>
    friend void h(...) requires True<U> {}

    template<typename S>
    friend void g(...) requires True<S>;
  };

template<typename S>
void g(...) requires True<S> {}

void call() {
    A<int> ai;
    h<void>(ai);
    g<void>(ai);
}
}

In the above snippet:

  • the call h<void>(ai) is mangled as _ZN5test21hIvEEvzQ4TrueITL0__E. Note that the constrained parameter U is mangled as TL0_ (4TrueITL0__E), i.e., a second-level template parameter (presumably the next level after the template parameters of the enclosing class A). Note that the enclosing class template specialization A<int> is not part of the mangling.
  • the call g<void>(ai) is mangled as _ZN5test21gIvEEvzQ4TrueIT_E. Note that the constrained parameter U is mangled as T_ (4TrueIT_E), i.e., a first-level template parameter.
  • the difference between h and g is that the definition of friend template function h is inside of struct A, and the definition of g is outside. Otherwise, their signatures are identical.

The mangling of h<void>(ai) makes it impossible to implement demangling of template parameter substitutions, since the substitution TL0_ cannot be demangled.

Options:

The latter option seems to fit better into the proposal in itanium-cxx-abi/cxx-abi#24 (comment).

Metadata

Metadata

Assignees

Labels

ABIApplication Binary Interfaceclang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptslibc++abilibc++abi C++ Runtime Library. Not libc++.tools:llvm-cxxfilt

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions