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] Lambda with explicit template parameter and requires clause that uses a dependent variable template is incorrectly rejected #61387

Closed
brycelelbach opened this issue Mar 13, 2023 · 3 comments
Labels
c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@brycelelbach
Copy link

brycelelbach commented Mar 13, 2023

Top of trunk Clang rejects the following code:

template <typename T> concept C = true;
template <typename T> constexpr bool I = true;

template <typename T> requires(C<T>) auto a(T&& t) { };
template <typename T> requires(I<T>) auto b(T&& t) { };

auto c = [] <typename T> requires(C<T>) (T&& t) { };
auto d = [] <typename T> requires(I<T>) (T&& t) { };

complaining that:

<source>:8:42: error: 'T' does not refer to a value
auto d = [] <typename T> requires(I<T>) (T&& t) { };
                                         ^
<source>:8:23: note: declared here
auto d = [] <typename T> requires(I<T>) (T&& t) { };
                      ^
<source>:8:46: error: use of undeclared identifier 't'
auto d = [] <typename T> requires(I<T>) (T&& t) { };
                                             ^
2 errors generated.
Compiler returned: 1

If a concept is used instead of an variable template, the code compiles fine. A function definition of similar construction (explicit template parameter and a use of a dependent variable template in the requires clause) is also fine.

GCC and MSVC both accept this code.

Godbolt reproducer.

@EugeneZelenko EugeneZelenko added c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed new issue labels Mar 13, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 13, 2023

@llvm/issue-subscribers-clang-frontend

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 13, 2023

@llvm/issue-subscribers-c-20

@shafik
Copy link
Collaborator

shafik commented Mar 13, 2023

This is #61278

CC @erichkeane

@rymiel rymiel closed this as completed in 6acdf58 Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

4 participants