https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90675
Bug ID: 90675
Summary: [concepts] expressions in compound requirements not
correctly treated as unevaluated operands
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: Casey at Carter dot net
Target Milestone: ---
Created attachment 46430
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46430&action=edit
Minimal repro
Compiling this well-formed TU:
template<class>
constexpr bool always_false = false;
template<class T>
struct S {
void f() {
static_assert(always_false<T>);
}
};
template<class>
concept True = true;
template<class T>
concept C = requires(T t) {
#ifndef WORKAROUND
{ t.f() } -> True;
#else
t.f();
requires True<decltype(t.f())>;
#endif
};
int main() {
static_assert(C<S<void>>);
}
with "g++ -std=c++2a -fconcepts" (same behavior for all versions from 6.1 to
today's trunk) diagnoses (https://godbolt.org/z/cHC8PE):
<source>: In instantiation of 'void S<T>::f() [with T = void]':
<source>:25:19: required from here
<source>:7:19: error: static assertion failed
7 | static_assert(always_false<T>);
| ^~~~~~~~~~~~~~~
Compiler returned: 1
Defining "WORKAROUND" allows the program to compile correctly, since the
expression appears in a simple-requirement rather than a compound-requirement.