Skip to content

[clang-cl] Cannot mangle decltype when used in an unevaluated context #118241

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

Open
MaxEW707 opened this issue Dec 2, 2024 · 2 comments
Open

[clang-cl] Cannot mangle decltype when used in an unevaluated context #118241

MaxEW707 opened this issue Dec 2, 2024 · 2 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" platform:windows

Comments

@MaxEW707
Copy link
Contributor

MaxEW707 commented Dec 2, 2024

https://godbolt.org/z/cGsG8T4G7

template<typename T, typename = void>
struct Widget;

template <class T>
struct Widget<T, decltype(T::test2([](){}))> 
{
};

struct Baz
{
    template<typename F>
    static constexpr decltype(auto) test2(F&& f) {}
};

void test()
{
    Widget<Baz> w;
}

Similar issue as #115990 which is fixed here #117845.

test2 must be instantiated since it has a deduced return type. The instantiation of the lambda is within the context of the uninstantiated Widget template. CodeGen has no way to know that a template argument is defined inside an uninstantiated template. So the function get put into DeferredDecls which is keyed off of the mangled name of the function so we need to mangle the decltype.

@MaxEW707 MaxEW707 added clang:codegen IR generation bugs: mangling, exceptions, etc. platform:windows labels Dec 2, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 2, 2024

@llvm/issue-subscribers-clang-codegen

Author: Max Winkler (MaxEW707)

https://godbolt.org/z/cGsG8T4G7 ``` template<typename T, typename = void> struct Widget;

template <class T>
struct Widget<T, decltype(T::test2({}))>
{
};

struct Baz
{
template<typename F>
static constexpr decltype(auto) test2(F&& f) {}
};

void test()
{
Widget<Baz> w;
}


Similar issue as https://github.com/llvm/llvm-project/issues/115990 which is fixed here https://github.com/llvm/llvm-project/pull/117845.

`test2` must be instantiated since it has a deduced return type. The instantiation of the lambda is within the context of the uninstantiated Widget template. CodeGen has no way to know that a template argument is defined inside an uninstantiated template. So the functions get put into `DeferredDecls` which is keyed off of the mangled name of the function so we need to mangle the `decltype`.
</details>

@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed clang:codegen IR generation bugs: mangling, exceptions, etc. labels Dec 2, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 2, 2024

@llvm/issue-subscribers-clang-frontend

Author: Max Winkler (MaxEW707)

https://godbolt.org/z/cGsG8T4G7 ``` template<typename T, typename = void> struct Widget;

template <class T>
struct Widget<T, decltype(T::test2({}))>
{
};

struct Baz
{
template<typename F>
static constexpr decltype(auto) test2(F&& f) {}
};

void test()
{
Widget<Baz> w;
}


Similar issue as https://github.com/llvm/llvm-project/issues/115990 which is fixed here https://github.com/llvm/llvm-project/pull/117845.

`test2` must be instantiated since it has a deduced return type. The instantiation of the lambda is within the context of the uninstantiated Widget template. CodeGen has no way to know that a template argument is defined inside an uninstantiated template. So the function get put into `DeferredDecls` which is keyed off of the mangled name of the function so we need to mangle the `decltype`.
</details>

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" platform:windows
Projects
None yet
Development

No branches or pull requests

3 participants