llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

clang c++20: rejects code when using a immediately invoked lambda in a concept

Open techatrix opened this issue 4 years ago • 4 comments

template <class T>
concept always_true = []() { return true; }();

template <class T>
constexpr auto foo() requires(always_true<T>) { return true; }

static_assert(foo<int>());

https://godbolt.org/z/EebsTsz9o

techatrix avatar Mar 14 '22 23:03 techatrix

@llvm/issue-subscribers-c-20

llvmbot avatar Mar 14 '22 23:03 llvmbot

@llvm/issue-subscribers-clang-frontend

llvmbot avatar Mar 14 '22 23:03 llvmbot

This is the same issue as a lot of other lambda related bugs. We do not have a good way to know that we are not in a dependent context in TreeTransform::TransformLambdaExpr, so we incorrectly make the lambda type - which is created, rather than transformed - dependent, and that causes issues down the line.

cor3ntin avatar Mar 28 '22 16:03 cor3ntin

This is fixed at head now.

usx95 avatar Oct 05 '22 15:10 usx95