https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103760
Bug ID: 103760
Summary: Invalid expression inside lambda inside compound
requirement causes an error instead of concept
satisfaction failure
Product: gcc
Version: 10.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jacek.olczyk98 at gmail dot com
Target Milestone: ---
When using a lambda expression in a requires clause compound requirement,
placing an expression invalid for some type T inside the lambda causes a
compile error during instantiation, instead of the expected behavior of causing
the concept to not be satisfied.
On clang, the behavior is as expected.
This happens on 10.2, where I discovered it, as well as on trunk.
Here is the code: https://godbolt.org/z/EnK5G8Yjf
To save a click, the example code is:
template<typename T>
concept Concept = requires (T x) {
{[](){ return T::foo; }()};
};
static_assert(!Concept<int>);
The expected behavior is to pass the static_assert.
The actual error is:
<source>: In lambda function:
<source>:3:22: error: 'foo' is not a member of 'int'
3 | {[](){ return T::foo; }()};
| ^~~