From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 49DBF384404C; Tue, 20 Oct 2020 03:20:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49DBF384404C From: "ppalka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/95310] [concepts] Unrelated template parameters printed in diagnostic Date: Tue, 20 Oct 2020 03:20:35 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: ppalka at gcc dot gnu.org X-Bugzilla-Status: NEW 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: Message-ID: In-Reply-To: References: 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: Tue, 20 Oct 2020 03:20:35 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95310 --- Comment #4 from Patrick Palka --- (In reply to ensadc from comment #3) > When verifying the fix, I noticed a new bug: Thanks for the heads up. >=20 > =3D=3D=3D=3D > template requires true > using iter_reference_t =3D decltype(*T{}); >=20 > template > struct result { > using type =3D iter_reference_t; > }; >=20 > template > concept indirectly_writable =3D requires(Out&& o, T&& t) { > iter_reference_t(*o) =3D 0; > }; >=20 > template > requires indirectly_writable> > void copy(In in, Out out) {} >=20 > void test(const int* p, int* q) { > copy(q, p); > } >=20 > =3D=3D=3D=3D > : In function 'void test(const int*, int*)': > :19:14: error: no matching function for call to 'copy(int*&, const > int*&)' > 19 | copy(q, p); > | ^ > :16:6: note: candidate: 'template requires= =20 > indirectly_writable void copy(In, Out)' > 16 | void copy(In in, Out out) {} > | ^~~~ > :16:6: note: template argument deduction/substitution failed: > :16:6: note: constraints not satisfied > : In substitution of 'template requires=20 > indirectly_writable void copy(In, Out) [with In =3D i= nt*; > Out =3D const int*]': > :19:14: required from here > :10:9: required for the satisfaction of 'indirectly_writable iter_reference_t >' [with Out =3D const int*; In =3D int*] > :10:31: in requirements with 'Out&& o', 'T&& t' [with T =3D int= &; > Out =3D const int*] > :11:29: note: the required expression 'decltype(*{})(*o)=3D0' is > invalid > 11 | iter_reference_t(*o) =3D 0; > | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ > cc1plus: note: set '-fconcepts-diagnostics-depth=3D' to at least 2 for mo= re > detail > =3D=3D=3D=3D >=20 > In >=20 > :10:9: required for the satisfaction of > 'indirectly_writable >' [with Out =3D const int*= ; In > =3D int*] >=20 > Note the mismatch between `F` and `In`. >=20 > GCC 10.2 prints `F =3D int*` instead of `In =3D int*`: >=20 > :10:9: required for the satisfaction of > 'indirectly_writable >' [with Out =3D const int*= ; F =3D > int*] >=20 > The name `F` comes from a completely unrelated class template, but at lea= st > the names match in GCC 10.2. >=20 > (Interestingly, the alias template is not expanded in this line.) Hmm, so the r11-3373 patch fixed only the printing of template parameters within the constraint's parameter mapping, i.e. within the [with ...] part = of the diagnostic. But as your latest testcase shows, within the diagnostic t= he constraint itself could also refer to an unrelated template parameter. To = fix this part of the diagnostic I think we would have to more generally fix PR6= 6968 once and for all..=