llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.03k stars 11.58k forks source link

[clang-cl] NTTP on template functions returning `auto` are mismangled by clang-cl #92204

Open MaxEW707 opened 4 months ago

MaxEW707 commented 4 months ago

https://godbolt.org/z/WPPraqE1E

template <auto a>
auto AutoFunc() {
  return a;
}

template <class T, T a>
auto FuncT() {
  return a;
}

template<class T, T a>
struct Foo
{
    Foo() {}
};

int main()
{   
    // Clang    : ??$FuncT@H$0A@@@YA?A?<auto>@@XZ
    // MSVC 1929: ??$FuncT@H$0A@@@YA?A_PXZ
    // MSVC 1916: ??$FuncT@H$0A@@@YAHXZ
    FuncT<int, 0>();

    // Clang    : ??$AutoFunc@$0A@@@YA?A?<auto>@@XZ
    // MSVC 1929: ??$AutoFunc@$MH0A@@@YA?A_PXZ
    // MSVC 1916: ??$AutoFunc@$0A@@@YAHXZ
    AutoFunc<0>();

    // Clang    : ??0?$Foo@H$0A@@@QEAA@XZ
    // MSVC 1929: ??0?$Foo@H$0A@@@QEAA@XZ
    // MSVC 1916: ??0?$Foo@H$0A@@@QEAA@XZ
    Foo<int, 0> _f;
}
llvmbot commented 1 month ago

@llvm/issue-subscribers-clang-codegen

Author: Max Winkler (MaxEW707)

https://godbolt.org/z/WPPraqE1E ```cpp template <auto a> auto AutoFunc() { return a; } template <class T, T a> auto FuncT() { return a; } template<class T, T a> struct Foo { Foo() {} }; int main() { // Clang : ??$FuncT@H$0A@@@YA?A?<auto>@@XZ // MSVC 1929: ??$FuncT@H$0A@@@YA?A_PXZ // MSVC 1916: ??$FuncT@H$0A@@@YAHXZ FuncT<int, 0>(); // Clang : ??$AutoFunc@$0A@@@YA?A?<auto>@@XZ // MSVC 1929: ??$AutoFunc@$MH0A@@@YA?A_PXZ // MSVC 1916: ??$AutoFunc@$0A@@@YAHXZ AutoFunc<0>(); // Clang : ??0?$Foo@H$0A@@@QEAA@XZ // MSVC 1929: ??0?$Foo@H$0A@@@QEAA@XZ // MSVC 1916: ??0?$Foo@H$0A@@@QEAA@XZ Foo<int, 0> _f; } ```
llvmbot commented 1 month ago

@llvm/issue-subscribers-c-1

Author: Max Winkler (MaxEW707)

https://godbolt.org/z/WPPraqE1E ```cpp template <auto a> auto AutoFunc() { return a; } template <class T, T a> auto FuncT() { return a; } template<class T, T a> struct Foo { Foo() {} }; int main() { // Clang : ??$FuncT@H$0A@@@YA?A?<auto>@@XZ // MSVC 1929: ??$FuncT@H$0A@@@YA?A_PXZ // MSVC 1916: ??$FuncT@H$0A@@@YAHXZ FuncT<int, 0>(); // Clang : ??$AutoFunc@$0A@@@YA?A?<auto>@@XZ // MSVC 1929: ??$AutoFunc@$MH0A@@@YA?A_PXZ // MSVC 1916: ??$AutoFunc@$0A@@@YAHXZ AutoFunc<0>(); // Clang : ??0?$Foo@H$0A@@@QEAA@XZ // MSVC 1929: ??0?$Foo@H$0A@@@QEAA@XZ // MSVC 1916: ??0?$Foo@H$0A@@@QEAA@XZ Foo<int, 0> _f; } ```