[Bug c++/81178] New: [concepts] poor (partial?) diagnostic for alias substitution failure in a concept body
Casey at Carter dot net
gcc-bugzilla@gcc.gnu.org
Thu Jun 22 15:19:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81178
Bug ID: 81178
Summary: [concepts] poor (partial?) diagnostic for alias
substitution failure in a concept body
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: Casey at Carter dot net
Target Milestone: ---
GCC 6.3/7.1/trunk as of 20170621 all diagnose this ill-formed program
(https://wandbox.org/permlink/uatmNSnlLbhvSvls):
template<class>
concept bool C1 = true;
template<class T>
using alias = typename T::type;
template<class T>
concept bool C2 = C1<alias<T>>;
void bar(C2) {}
int main() { bar(42); }
with:
prog.cc: In function 'int main()':
prog.cc:12:20: error: cannot call function 'void bar(auto:1) [with auto:1 =
int]'
int main() { bar(42); }
^
prog.cc:10:6: note: constraints not satisfied
void bar(C2) {}
^~~
prog.cc:10:6: note: in the expansion of concept 'C2<auto:1> template<class T>
concept const bool C2<T> [with T = int]'
(Yes, that is the entire diagnostic.) If we expand the definition of C2 fully
into bar (https://wandbox.org/permlink/GKW0vWSPIY5XrGRE):
template<class T>
requires C1<alias<T>>
void bar(T) {}
the compiler gives a more complete diagnostic:
prog.cc: In function 'int main()':
prog.cc:14:20: error: cannot call function 'void bar(T) [with T = int]'
int main() { bar(42); }
^
prog.cc:12:6: note: constraints not satisfied
void bar(T) {}
^~~
prog.cc:12:6: note: invalid use of the concept 'C1<typename T::type>'
prog.cc:14:20: error: 'int' is not a class, struct, or union type
int main() { bar(42); }
^
More information about the Gcc-bugs
mailing list