https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92806
Bug ID: 92806 Summary: Suboptimal diagnostic for concept that depends on non-bool value Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Blocks: 67491 Target Milestone: --- template<typename T> struct trait { enum { value = 1 }; }; template<typename T> concept foo = trait<T>::value; static_assert(foo<int>); Compiled with -std=gnu++2a: nonbool.cc:8:9: required by the constraints of 'template<class T> concept foo' nonbool.cc:10:24: error: constraint does not have type 'bool' 10 | static_assert(foo<int>); | ^ nonbool.cc:10:15: error: non-constant condition for static assertion 10 | static_assert(foo<int>); | ^~~~~~~~ nonbool.cc:8:9: required by the constraints of 'template<class T> concept foo' nonbool.cc:10:15: error: constraint does not have type 'bool' It's not clear from the diagnostic that the problem is trait<T>::value on line 8, so the user is left thinking "how can a concept not have type 'bool'?!" The fix is something like: template<typename T> concept foo = (bool)trait<T>::value; ^~~~~~ so it would be helpful to diagnose the non-bool type at the location of the concept definition, not its use. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67491 [Bug 67491] [meta-bug] concepts issues