https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117294

--- Comment #6 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
With the above patch, the original testcase now gives the following diagnostic
(using experimental-nesting=yes for clarity):

$ g++-16 -std=c++20 -S -fdiagnostics-set-output=text:experimental-nesting=yes
test.cpp
test.cpp: In function ‘auto tryit()’:
test.cpp:19:24: error: no matching function for call to ‘make<Foo<A> >()’
   19 |     return make<Foo<A>>();
      |            ~~~~~~~~~~~~^~
  • there is 1 candidate
    • candidate 1: ‘template<class T>  requires  default_initializable<T> auto
make()’
      test.cpp:4:6:
          4 | auto make() {
            |      ^~~~
      • template argument deduction/substitution failed:
        • constraints not satisfied
In file included from test.cpp:1:
          • /home/wreien/.local/include/c++/16.0.0/concepts: In substitution of
‘template<class T>  requires  default_initializable<T> auto make() [with T =
Foo<A>]’:
          • required from here
            test.cpp:19:24:
               19 |     return make<Foo<A>>();
                  |            ~~~~~~~~~~~~^~
          • required for the satisfaction of ‘constructible_from<_Tp>’ [with
_Tp = Foo<A>]
            /home/wreien/.local/include/c++/16.0.0/concepts:161:13:
              161 |     concept constructible_from
                  |             ^~~~~~~~~~~~~~~~~~
          • required for the satisfaction of ‘default_initializable<T>’ [with T
= Foo<A>]
            /home/wreien/.local/include/c++/16.0.0/concepts:166:13:
              166 |     concept default_initializable = constructible_from<_Tp>
                  |             ^~~~~~~~~~~~~~~~~~~~~
          • the expression ‘is_constructible_v<_Tp, _Args ...> [with _Tp =
Foo<A>; _Args = {}]’ evaluated to ‘false’
            /home/wreien/.local/include/c++/16.0.0/concepts:162:30:
              162 |       = destructible<_Tp> && is_constructible_v<_Tp,
_Args...>;
                  |                             
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          • ‘Foo<A>’ is not default constructible, because
          • test.cpp: In instantiation of ‘constexpr Foo<A>::Foo()’:
          • required by substitution of ‘template<class T>  requires 
default_initializable<T> auto make() [with T = Foo<A>]’
            /home/wreien/.local/include/c++/16.0.0/concepts:162:30:
          • required from here
            test.cpp:19:24:
               19 |     return make<Foo<A>>();
                  |            ~~~~~~~~~~~~^~
          • error: could not convert ‘1’ from ‘int’ to ‘A’
            test.cpp:15:11:
               15 |     T a = 1;
                  |           ^
                  |           |
                  |           int

This is still not perfect, there's a chunk of extra noise, and the ordering of
the diagnostics IMO could have improvement, but at least the relevant
information is there now.

Reply via email to