public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/99525] New: wrong location of implicitly generated assignment to polymorphic class
@ 2021-03-10 18:57 msebor at gcc dot gnu.org
2021-03-10 21:26 ` [Bug middle-end/99525] " msebor at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-10 18:57 UTC (permalink / raw)
To: gcc-bugs
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];
| ^
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug middle-end/99525] wrong location of implicitly generated assignment to polymorphic class
2021-03-10 18:57 [Bug middle-end/99525] New: wrong location of implicitly generated assignment to polymorphic class msebor at gcc dot gnu.org
@ 2021-03-10 21:26 ` msebor at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-10 21:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99525
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The (otherwise untested) change below corrects the location:
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 1dcb31c0267..c77745b788d 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -4938,7 +4938,7 @@ expand_call_inline (basic_block bb, gimple *stmt,
copy_body_data *id,
/* Record the function we are about to inline. */
id->src_fn = fn;
id->src_cfun = DECL_STRUCT_FUNCTION (fn);
- id->reset_location = DECL_IGNORED_P (fn);
+ id->reset_location = DECL_IGNORED_P (fn) || DECL_ARTIFICIAL (fn);
id->call_stmt = call_stmt;
/* When inlining into an OpenMP SIMD-on-SIMT loop, arrange for new automatic
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-10 21:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 18:57 [Bug middle-end/99525] New: wrong location of implicitly generated assignment to polymorphic class msebor at gcc dot gnu.org
2021-03-10 21:26 ` [Bug middle-end/99525] " msebor at gcc dot gnu.org
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).