Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Clang][Windows] Microsoft mangling cannot handle lambda in decltype in return type #131611

Open
MagentaTreehouse opened this issue Mar 17, 2025 · 3 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" lambda C++11 lambda expressions

Comments

@MagentaTreehouse
Copy link
Contributor

Given this code:

template <class>
struct B {};

struct A {
    template <class T>
    auto f(T) -> B<decltype([] (T) {})> {
        return {};
    }
};

int main() {
    A{}.f(0);
}

Clang on Windows error:

<source>(6,5): error: cannot mangle this template specialization type yet
    6 |     auto f(T) -> B<decltype([] (T) {})> {
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    7 |         return {};
      |         ~~~~~~~~~~
    8 |     }
      |     ~

Similar error happens on simpler code:

template <class T> // must be a function template
auto f(T) -> decltype([] {}) {
    return {};
}
int main() { f(0)(); }

On other platforms with Itanium mangling, or if using MSVC, it can be compiled.

See https://compiler-explorer.com/z/vPz6E5ve7. (Compiler explorer seems to only have version 18 for clang-cl)

I can reproduce this using the main branch.

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Mar 17, 2025
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" lambda C++11 lambda expressions and removed clang Clang issues not falling into any other category labels Mar 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 17, 2025

@llvm/issue-subscribers-clang-frontend

Author: None (MagentaTreehouse)

Given this code: ```c++ template <class> struct B {};

struct A {
template <class T>
auto f(T) -> B<decltype([] (T) {})> {
return {};
}
};

int main() {
A{}.f(0);
}


Clang on Windows error:
```console
&lt;source&gt;(6,5): error: cannot mangle this template specialization type yet
    6 |     auto f(T) -&gt; B&lt;decltype([] (T) {})&gt; {
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    7 |         return {};
      |         ~~~~~~~~~~
    8 |     }
      |     ~

Similar error happens on simpler code:

template &lt;class T&gt; // must be a function template
auto f(T) -&gt; decltype([] {}) {
    return {};
}
int main() { f(0)(); }

On other platforms with Itanium mangling, or if using MSVC, it can be compiled.

See https://compiler-explorer.com/z/vPz6E5ve7. (Compiler explorer seems to only have version 18 for clang-cl)

I can reproduce this using the main branch.

@shafik
Copy link
Collaborator

shafik commented Mar 17, 2025

CC @AaronBallman

@zyn0217
Copy link
Contributor

zyn0217 commented Mar 18, 2025

@cor3ntin another case of unevaluated lambdas in MS ABI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" lambda C++11 lambda expressions
Projects
None yet
Development

No branches or pull requests

5 participants