From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6B8C63858C3A; Fri, 10 Dec 2021 00:40:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B8C63858C3A From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/71982] Wrong error and note range with macro Date: Fri, 10 Dec 2021 00:40:26 +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: 7.0 X-Bugzilla-Keywords: diagnostic, needs-bisection X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia 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: Fri, 10 Dec 2021 00:40:26 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D71982 --- Comment #3 from Andrew Pinski --- Trunk gives: [apinski@xeond2 src]$ ~/upstream-gcc/bin/gcc t.cc t.cc: In instantiation of =E2=80=98bool operator=3D=3D(const A&, const A= &) [with T =3D const B]=E2=80=99: t.cc:25:30: required from here t.cc:1:34: error: no match for =E2=80=98operator=3D=3D=E2=80=99 (operand ty= pes are =E2=80=98const B=E2=80=99 and =E2=80=98const B=E2=80=99) 1 | #define MACRO(left, right) *left =3D=3D *right | ^ t.cc:15:10: note: in expansion of macro =E2=80=98MACRO=E2=80=99 15 | return MACRO(_left, _right); | ^~~~~ t.cc:10:6: note: candidate: =E2=80=98template bool operator=3D=3D(= const A&, const A&)=E2=80=99 10 | bool operator=3D=3D(const A& left, const A& right) | ^~~~~~~~ t.cc:10:6: note: template argument deduction/substitution failed: t.cc:1:34: note: =E2=80=98const B=E2=80=99 is not derived from =E2=80=98c= onst A=E2=80=99 1 | #define MACRO(left, right) *left =3D=3D *right | ^ t.cc:15:10: note: in expansion of macro =E2=80=98MACRO=E2=80=99 15 | return MACRO(_left, _right); | ^~~~~ t.cc:24:6: note: candidate: =E2=80=98bool operator=3D=3D(C&, C&)=E2=80=99 24 | bool operator=3D=3D(C& left, C& right) { | ^~~~~~~~ t.cc:24:20: note: no known conversion for argument 1 from =E2=80=98const = B=E2=80=99 to =E2=80=98C&=E2=80=99 24 | bool operator=3D=3D(C& left, C& right) { | ~~~^~~~ Which looks fine. While GCC 10.1.0 gives: t.cc: In instantiation of 'bool operator=3D=3D(const A&, const A&) [w= ith T =3D const B]': t.cc:25:30: required from here t.cc:1:34: error: no match for 'operator=3D=3D' (operand types are 'const B= ' and 'const B') 1 | #define MACRO(left, right) *left =3D=3D *right | ~~~~~~^~~~~~~~~ 2 | | 3 | template | ~~~~~~~~~~~~~~~~~~~~~ 4 | struct A { .... This is on the same machine. This happens on both aarch64 and x86_64. The problem is not the code is being rejected (correctly) but the warning location includes so much more than it should in previous versions of GCC.=