Skip to content

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

Open
@MagentaTreehouse

Description

@MagentaTreehouse

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"lambdaC++11 lambda expressions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions