From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B0C74385803B; Wed, 10 Mar 2021 18:57:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B0C74385803B From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/99525] New: wrong location of implicitly generated assignment to polymorphic class Date: Wed, 10 Mar 2021 18:57:21 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor 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 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, 10 Mar 2021 18:57:21 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99525 Bug ID: 99525 Summary: wrong location of implicitly generated assignment to polymorphic class Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- The first warning points to the assignment expression in the calling functi= on.=20 But the second warning instead points to the class head instead, making it difficult to see what caused it. It too should point to the assignment expression in the calling function. The wrong location is first seen in the einline dump. $ cat x.C && gcc -O2 -S -Wall -fdump-tree-einline-lineno=3D/dev/stdout x.C struct X { int i; }; char a[sizeof (X) - 1]; void f (X x) { X *p =3D (X*)a; *p =3D x; } struct Y { int i; virtual ~Y (); }; void f (Y y) { Y *p =3D (Y*)a; *p =3D y; } ;; Function f (_Z1f1X, funcdef_no=3D0, decl_uid=3D2351, cgraph_uid=3D1, symbol_order=3D1) Iterations: 0 void f (struct X x) { struct X * p; : [x.C:10:6] p_1 =3D [x.C:10:14] &a; [x.C:11:6] [x.C:11:6] *p_1 =3D x; [x.C:12:1] return; } ;; Function Y::operator=3D (_ZN1YaSERKS_, funcdef_no=3D2, decl_uid=3D2391, cgraph_uid=3D2, symbol_order=3D2) Iterations: 0 struct Y & Y::operator=3D (struct Y * const this, const struct Y & D.2392) { int _1; struct Y & _6; : [x.C:14:8] _1 =3D _3(D)->i; [x.C:14:8] this_4(D)->i =3D _1; [x.C:14:8] _6 =3D this_4(D); [x.C:14:8] return _6; } ;; Function f (_Z1f1Y, funcdef_no=3D1, decl_uid=3D2388, cgraph_uid=3D3, symbol_order=3D3) Iterations: 1 Symbols to be put in SSA form { D.2402 } Incremental SSA update started at block: 0 Number of blocks in CFG: 5 Number of blocks to update: 4 ( 80%) Merging blocks 2 and 4 Merging blocks 2 and 3 void f (struct Y & y) { struct Y * p; int _5; : [x.C:22:6] p_1 =3D [x.C:22:14] &a; [x.C:14:8] _5 =3D MEM[(const struct Y &)y_3(D)].i; [x.C:14:8] p_1->i =3D _5; [x.C:24:1] return; } x.C: In function =E2=80=98void f(X)=E2=80=99: x.C:11:6: warning: array subscript =E2=80=98X[0]=E2=80=99 is partly outside= array bounds of =E2=80=98char [3]=E2=80=99 [-Warray-bounds] 11 | *p =3D x; | ~~~^~~ x.C:6:6: note: while referencing =E2=80=98a=E2=80=99 of size 0 6 | char a[sizeof (X) - 1]; | ^ x.C: In function =E2=80=98void f(Y)=E2=80=99: x.C:14:8: warning: array subscript =E2=80=98Y[0]=E2=80=99 is partly outside= array bounds of =E2=80=98char [3]=E2=80=99 [-Warray-bounds] 14 | struct Y | ^ x.C:6:6: note: while referencing =E2=80=98a=E2=80=99 of size 0 6 | char a[sizeof (X) - 1]; | ^=