public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-99525-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99525 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 function. 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=/dev/stdout x.C struct X { int i; }; char a[sizeof (X) - 1]; void f (X x) { X *p = (X*)a; *p = x; } struct Y { int i; virtual ~Y (); }; void f (Y y) { Y *p = (Y*)a; *p = y; } ;; Function f (_Z1f1X, funcdef_no=0, decl_uid=2351, cgraph_uid=1, symbol_order=1) Iterations: 0 void f (struct X x) { struct X * p; <bb 2> : [x.C:10:6] p_1 = [x.C:10:14] &a; [x.C:11:6] [x.C:11:6] *p_1 = x; [x.C:12:1] return; } ;; Function Y::operator= (_ZN1YaSERKS_, funcdef_no=2, decl_uid=2391, cgraph_uid=2, symbol_order=2) Iterations: 0 struct Y & Y::operator= (struct Y * const this, const struct Y & D.2392) { int _1; struct Y & _6; <bb 2> : [x.C:14:8] _1 = _3(D)->i; [x.C:14:8] this_4(D)->i = _1; [x.C:14:8] _6 = this_4(D); [x.C:14:8] return _6; } ;; Function f (_Z1f1Y, funcdef_no=1, decl_uid=2388, cgraph_uid=3, symbol_order=3) 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; <bb 2> : [x.C:22:6] p_1 = [x.C:22:14] &a; [x.C:14:8] _5 = MEM[(const struct Y &)y_3(D)].i; [x.C:14:8] p_1->i = _5; [x.C:24:1] return; } x.C: In function ‘void f(X)’: x.C:11:6: warning: array subscript ‘X[0]’ is partly outside array bounds of ‘char [3]’ [-Warray-bounds] 11 | *p = x; | ~~~^~~ x.C:6:6: note: while referencing ‘a’ of size 0 6 | char a[sizeof (X) - 1]; | ^ x.C: In function ‘void f(Y)’: x.C:14:8: warning: array subscript ‘Y[0]’ is partly outside array bounds of ‘char [3]’ [-Warray-bounds] 14 | struct Y | ^ x.C:6:6: note: while referencing ‘a’ of size 0 6 | char a[sizeof (X) - 1]; | ^
next reply other threads:[~2021-03-10 18:57 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-10 18:57 msebor at gcc dot gnu.org [this message] 2021-03-10 21:26 ` [Bug middle-end/99525] " msebor at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-99525-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).