From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 82EC33858419; Wed, 13 Jul 2022 20:11:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 82EC33858419 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106285] New: Reduce visual noise and confusing grouping when printing overload candidate errors Date: Wed, 13 Jul 2022 20:11:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2022 20:11:58 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106285 Bug ID: 106285 Summary: Reduce visual noise and confusing grouping when printing overload candidate errors Product: gcc Version: unknown Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- This is the same code as PR 106256: template class C { public: C() =3D default; template C(AA, BB) { } C(C&&) =3D default; private: struct __secret_tag { }; template C(AA&, BB&, __secret_tag) { } }; C c({}, {}); We get these errors: cons.C:20:21: error: no matching function for call to =E2=80=98C::C(, )=E2=80=99 20 | C c({}, {}); | ^ cons.C:16:5: note: candidate: =E2=80=98template C= ::C(AA&, BB&, __secret_tag) [with BB =3D AA; A =3D int; B =3D int]=E2=80=99 16 | C(AA&, BB&, __secret_tag) | ^ cons.C:16:5: note: template argument deduction/substitution failed: cons.C:20:21: note: candidate expects 3 arguments, 2 provided 20 | C c({}, {}); | ^ cons.C:8:5: note: candidate: =E2=80=98template C:= :C(AA, BB) [with BB =3D AA; A =3D int; B =3D int]=E2=80=99 8 | C(AA, BB) | ^ cons.C:8:5: note: template argument deduction/substitution failed: cons.C:20:21: note: couldn=E2=80=99t deduce template parameter =E2=80=98A= A=E2=80=99 20 | C c({}, {}); | ^ cons.C:11:3: note: candidate: =E2=80=98constexpr C::C(C&&) [wit= h A =3D int; B =3D int]=E2=80=99 11 | C(C&&) =3D default; | ^ cons.C:11:3: note: candidate expects 1 argument, 2 provided cons.C:5:3: note: candidate: =E2=80=98constexpr C::C() [with A =3D in= t; B =3D int]=E2=80=99 5 | C() =3D default; | ^ cons.C:5:3: note: candidate expects 0 arguments, 2 provided Why do the first and second candidates repeat the caller location: 20 | C c({}, {}); | ^ We've already shown that once with the "no matching function for call to ..= ." error at the top. Why are we repeating it? Isn't it just noise that makes t= he candidate list harder to read? Secondly, currently we show the candidate, then its declaration, then the reason it's not viable: cons.C:5:3: note: candidate: =E2=80=98constexpr C::C() [with A =3D in= t; B =3D int]=E2=80=99 5 | C() =3D default; | ^ cons.C:5:3: note: candidate expects 0 arguments, 2 provided However, when that's in the middle of a long list of candidates, it's hard = to see where each new candidate begins. The two related notes are separated by= the caret diagnostic. Would it make more sense to group the reason with the candidate, i.e.: cons.C:5:3: note: candidate: =E2=80=98constexpr C::C() [with A =3D in= t; B =3D int]=E2=80=99 cons.C:5:3: note: candidate expects 0 arguments, 2 provided 5 | C() =3D default; | ^ If we combine these suggestions (remove repeated caret showing call site, a= nd putting the decl caret after the failure reason, and the PR 106281 ordering change) I think the result is much better: cons.C:20:21: error: no matching function for call to =E2=80=98C::C(, )=E2=80=99 20 | C c({}, {}); | ^ cons.C:8:5: note: candidate: =E2=80=98template C:= :C(AA, BB) [with BB =3D AA; A =3D int; B =3D int]=E2=80=99 cons.C:8:5: note: template argument deduction/substitution failed: cons.C:20:21: note: couldn=E2=80=99t deduce template parameter =E2=80=98A= A=E2=80=99 8 | C(AA, BB) | ^ cons.C:11:3: note: candidate: =E2=80=98constexpr C::C(C&&) [wit= h A =3D int; B =3D int]=E2=80=99 cons.C:11:3: note: candidate expects 1 argument, 2 provided 11 | C(C&&) =3D default; | ^ cons.C:5:3: note: candidate: =E2=80=98constexpr C::C() [with A =3D in= t; B =3D int]=E2=80=99 cons.C:5:3: note: candidate expects 0 arguments, 2 provided 5 | C() =3D default; | ^ cons.C:16:5: note: candidate: =E2=80=98template C= ::C(AA&, BB&, __secret_tag) [with BB =3D AA; A =3D int; B =3D int]=E2=80=99 cons.C:16:5: note: template argument deduction/substitution failed: cons.C:20:21: note: candidate expects 3 arguments, 2 provided 16 | C(AA&, BB&, __secret_tag) | ^=