Skip to content

Clang requires lambda-capturing constexpr values when creating a named dependent type #55617

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
wthrowe opened this issue May 20, 2022 · 2 comments
Labels
c++17 clang:frontend Language frontend issues, e.g. anything involving "Sema" rejects-valid

Comments

@wthrowe
Copy link

wthrowe commented May 20, 2022

Code is rejected as C++17 on clang-14.0.0 and current trunk. Godbolt: https://godbolt.org/z/YPq3sza68

template <typename T>
void f() {
    constexpr int x = 1;
    const auto test1 = []() { T y{x}; };  // error: variable 'x' cannot be implicitly captured in a lambda with no capture-default specified
    const auto test2 = []() { T{x}; };  // Accepted
    const auto test3 = []() { int y{x}; };  // Accepted
    const auto test4 = [&x]() { T y{x}; };  // Accepted, warns capture is unnecessary when `f<int>` is intantiated
}
@EugeneZelenko EugeneZelenko added c++17 clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed new issue labels May 20, 2022
@llvmbot
Copy link
Member

llvmbot commented May 20, 2022

@llvm/issue-subscribers-c-17

@llvmbot
Copy link
Member

llvmbot commented May 20, 2022

@llvm/issue-subscribers-clang-frontend

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

No branches or pull requests

4 participants