https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117294
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Interestingly, Clang *does* say why the concept failed, and says that there was
an explicit constructor that wasn't a candidate. But it also prints notes about
implicit copy constructor and implicit move constructor (which don't seem
useful) and it says that the ill-formed conversion from '1' to 'A' occurred "in
evaluation of exception specification for 'Foo<A>::Foo'" which is just
confusing.
def.cc:15:11: error: no viable conversion from 'int' to 'A'
15 | T a = 1;
| ^
def.cc:14:8: note: in instantiation of default member initializer 'Foo<A>::a'
requested here
14 | struct Foo {
| ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/type_traits:3383:46:
note: in evaluation of exception specification for 'Foo<A>::Foo' needed here
3383 | inline constexpr bool is_constructible_v = __is_constructible(_Tp,
_Args...);
| ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/concepts:160:30:
note: in instantiation of variable template specialization
'std::is_constructible_v<Foo<A>>' requested here
160 | = destructible<_Tp> && is_constructible_v<_Tp, _Args...>;
| ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/concepts:160:30:
note: while substituting template arguments into constraint expression here
160 | = destructible<_Tp> && is_constructible_v<_Tp, _Args...>;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/concepts:164:37:
note: while checking the satisfaction of concept 'constructible_from<Foo<A>>'
requested here
164 | concept default_initializable = constructible_from<_Tp>
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/concepts:164:37:
note: while substituting template arguments into constraint expression here
164 | concept default_initializable = constructible_from<_Tp>
| ^~~~~~~~~~~~~~~~~~~~~~~
def.cc:3:11: note: while checking the satisfaction of concept
'default_initializable<Foo<A>>' requested here
3 | template <std::default_initializable T>
| ^
def.cc:3:11: note: while substituting template arguments into constraint
expression here
3 | template <std::default_initializable T>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
def.cc:20:10: note: while checking constraint satisfaction for template
'make<Foo<A>>' required here
20 | return make<Foo<A>>();
| ^~~~
def.cc:20:10: note: in instantiation of function template specialization
'make<Foo<A>>' requested here
def.cc:9:8: note: candidate constructor (the implicit copy constructor) not
viable: no known conversion from 'int' to 'const A &' for 1st argument
9 | struct A {
| ^
def.cc:9:8: note: candidate constructor (the implicit move constructor) not
viable: no known conversion from 'int' to 'A &&' for 1st argument
9 | struct A {
| ^
def.cc:10:14: note: explicit constructor is not a candidate
10 | explicit A(int) {}
| ^
def.cc:20:10: error: no matching function for call to 'make'
20 | return make<Foo<A>>();
| ^~~~~~~~~~~~
def.cc:4:6: note: candidate template ignored: constraints not satisfied [with T
= Foo<A>]
4 | auto make() {
| ^
def.cc:3:11: note: because 'Foo<A>' does not satisfy 'default_initializable'
3 | template <std::default_initializable T>
| ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/concepts:167:2:
note: because '_Tp{}' would be invalid
167 | _Tp{};
| ^
2 errors generated.
Why is it showing anything about _Tp{} when the earlier constructible_from<_Tp>
requirement already failed?