https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72682
Bug ID: 72682 Summary: Redundant concept diagnostics when the same concept is checked multiple times Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: adrian.wielgosik at gmail dot com Target Milestone: --- A simple code example: template<typename T> using id=T; template<typename T> concept bool A = requires(T a) { a==a; }; template<typename T, typename U> concept bool B = A<T> && // (1) basic usage A<T> && // (2) duplicate concept check A<U> && // (3) different concept check that happens to check the same type A<id<T>>; // (4) same as above template<typename T> requires B<T, T> void f(T){} struct S{} s; int main(){ f(s); } Produces the following diagnostic (first couple of lines that were not relevant were omitted): main.cpp:4:14: note: within ‘template<class T> concept const bool A<T> [with T = S]’ concept bool A = requires(T a) { a==a; }; ^ main.cpp:4:14: note: with ‘S a’ main.cpp:4:14: note: the required expression ‘(a == a)’ would be ill-formed main.cpp:4:14: note: within ‘template<class T> concept const bool A<T> [with T = S]’ main.cpp:4:14: note: with ‘S a’ main.cpp:4:14: note: the required expression ‘(a == a)’ would be ill-formed main.cpp:4:14: note: within ‘template<class T> concept const bool A<T> [with T = S]’ main.cpp:4:14: note: with ‘S a’ main.cpp:4:14: note: the required expression ‘(a == a)’ would be ill-formed main.cpp:4:14: note: within ‘template<class T> concept const bool A<T> [with T = S]’ main.cpp:4:14: note: with ‘S a’ main.cpp:4:14: note: the required expression ‘(a == a)’ would be ill-formed Notice that all four checks in the end checked the concept A on the type S and produced the exact same diagnostic. For a real world example: if you use Ranges TS StrictTotallyOrdered<T, T> on unorderable type, it's going to check StrictTotallyOrdered<T> three times on the same type (and then also check all operators like "{t < u}->Boolean" extra two times, and then a duplicate check of EqualityComparable), which can easily produce over a dozen redundant messages, while ideally the whole diagnostic should contain only six messages, one for each comparison operator.