[Bug c++/101006] New: Request diagnostic for likely concept syntax errors
barry.revzin at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Jun 10 01:23:59 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101006
Bug ID: 101006
Summary: Request diagnostic for likely concept syntax errors
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: barry.revzin at gmail dot com
Target Milestone: ---
Consider the following:
template <typename T>
concept Thing = true;
template <typename T>
concept MemberThing = requires (T t) {
t.member() -> Thing; // #1
!requires { t.member(); }; // #2
};
These are likely intended to be (obviously not at the same time, this is just
an example):
template <typename T>
concept MemberThing = requires (T t) {
{ t.member() } -> Thing;
requires !requires { t.member(); };
};
But #1 is very likely to be a bug, and #2 is completely pointless as a
requirement since it's tautologically true. It would be nice if gcc could
produce warnings in such cases.
#2 is a similar case to the P2092 fixup of:
template <typename T>
concept MemberThing = requires (T t) {
requires { t.member(); };
};
which is now ill-formed. However, gcc's diagnostic here could be more helpful
too (perhaps including a fixup for an extra requires?)
<source>:6:14: error: expected primary-expression before '{' token
6 | requires { t.member(); };
| ^
#1 might be harder to warn about since that could *theoretically* be intended,
but if unqualified lookup for Thing actually finds a concept, seems like a good
bet for a diagnostic maybe?
More information about the Gcc-bugs
mailing list