public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/103720] New: bogus warning from -Wuninitialized + -ftrivial-auto-var-init + O2
@ 2021-12-14 20:57 qinzhao at gcc dot gnu.org
2021-12-14 22:11 ` [Bug middle-end/103720] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: qinzhao at gcc dot gnu.org @ 2021-12-14 20:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103720
Bug ID: 103720
Summary: bogus warning from -Wuninitialized +
-ftrivial-auto-var-init + O2
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: qinzhao at gcc dot gnu.org
Target Milestone: ---
There are multiple bogus warnings from -Wuninitialized +
-ftrivial-auto-var-init when building linux kernel the the latest upstream gcc.
One of them is from building fs/proc/array.c.
and I used Creduce to reduce into the following small testing case:
[opc@qinzhao-ol8u3-x86 tem]$ cat t.c
typedef struct {
unsigned long a[4];
} b;
int e, g;
long f;
int *h();
int *i(j) {
int *a = h(j);
return a;
}
void k(b *j) {
for (e = 1; e <= 4; ++e) {
b *b = j;
b->a[0] = f;
}
}
int l() {
b c;
unsigned long d;
i(&d);
k(&c);
g = c.a[0];
return 0;
}
[opc@qinzhao-ol8u3-x86 tem]$ sh t
/home/opc/Install/latest-d/bin/gcc -O2 -Wall -std=gnu89 -Werror
-Wno-pointer-sign -ftrivial-auto-var-init=zero t.c -S
t.c: In function ‘l’:
t.c:19:17: error: ‘c.a[0]’ is used uninitialized [-Werror=uninitialized]
19 | unsigned long d;
| ^
t.c:18:5: note: ‘c.a[0]’ was declared here
18 | b c;
| ^
cc1: all warnings being treated as errors
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/103720] bogus warning from -Wuninitialized + -ftrivial-auto-var-init + O2
2021-12-14 20:57 [Bug middle-end/103720] New: bogus warning from -Wuninitialized + -ftrivial-auto-var-init + O2 qinzhao at gcc dot gnu.org
@ 2021-12-14 22:11 ` pinskia at gcc dot gnu.org
2021-12-14 22:53 ` [Bug tree-optimization/103720] " qinzhao at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-14 22:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103720
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-12-14
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=102608
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed,
Dom transformed:
c$a$0_6 = .DEFERRED_INIT (8, 2, 0);
_1 = .DEFERRED_INIT (8, 2, 0);
into:
c$a$0_6 = .DEFERRED_INIT (8, 2, 0);
_1 = c$a$0_6;
Which it should not be done. FRE had did the same thing but it was fixed, see
PR 102608.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/103720] bogus warning from -Wuninitialized + -ftrivial-auto-var-init + O2
2021-12-14 20:57 [Bug middle-end/103720] New: bogus warning from -Wuninitialized + -ftrivial-auto-var-init + O2 qinzhao at gcc dot gnu.org
2021-12-14 22:11 ` [Bug middle-end/103720] " pinskia at gcc dot gnu.org
@ 2021-12-14 22:53 ` qinzhao at gcc dot gnu.org
2022-01-12 15:53 ` qinzhao at gcc dot gnu.org
2022-01-12 15:54 ` qinzhao at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: qinzhao at gcc dot gnu.org @ 2021-12-14 22:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103720
--- Comment #2 from qinzhao at gcc dot gnu.org ---
(In reply to Andrew Pinski from comment #1)
>
> Dom transformed:
> c$a$0_6 = .DEFERRED_INIT (8, 2, 0);
> _1 = .DEFERRED_INIT (8, 2, 0);
>
> into:
> c$a$0_6 = .DEFERRED_INIT (8, 2, 0);
> _1 = c$a$0_6;
>
> Which it should not be done. FRE had did the same thing but it was fixed,
> see PR 102608.
Yes, looks like that the current definition of .DEFERRED_INIT might trigger
more other similar potential issues.
it's might be better to change the 3rd parameter from the current IS_VLA to a
string that represent the name of the original variable. then different
variables will map to a different .DEFERRED_INIT, as a result, all such
optimization will not happen anymore.
this can be combined with the patch to fix -Wuninitialized +
-ftrivial-auto-var-init for address taken variable issue as:
https://gcc.gnu.org/pipermail/gcc-patches/2021-December/586491.html
As I just checked, that patch did resolve this issue.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/103720] bogus warning from -Wuninitialized + -ftrivial-auto-var-init + O2
2021-12-14 20:57 [Bug middle-end/103720] New: bogus warning from -Wuninitialized + -ftrivial-auto-var-init + O2 qinzhao at gcc dot gnu.org
2021-12-14 22:11 ` [Bug middle-end/103720] " pinskia at gcc dot gnu.org
2021-12-14 22:53 ` [Bug tree-optimization/103720] " qinzhao at gcc dot gnu.org
@ 2022-01-12 15:53 ` qinzhao at gcc dot gnu.org
2022-01-12 15:54 ` qinzhao at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: qinzhao at gcc dot gnu.org @ 2022-01-12 15:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103720
--- Comment #3 from qinzhao at gcc dot gnu.org ---
this is fixed with the following commit in gcc12.
https://gcc.gnu.org/pipermail/gcc-cvs/2022-January/359118.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/103720] bogus warning from -Wuninitialized + -ftrivial-auto-var-init + O2
2021-12-14 20:57 [Bug middle-end/103720] New: bogus warning from -Wuninitialized + -ftrivial-auto-var-init + O2 qinzhao at gcc dot gnu.org
` (2 preceding siblings ...)
2022-01-12 15:53 ` qinzhao at gcc dot gnu.org
@ 2022-01-12 15:54 ` qinzhao at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: qinzhao at gcc dot gnu.org @ 2022-01-12 15:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103720
qinzhao at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #4 from qinzhao at gcc dot gnu.org ---
fixed in GCC12
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-01-12 15:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14 20:57 [Bug middle-end/103720] New: bogus warning from -Wuninitialized + -ftrivial-auto-var-init + O2 qinzhao at gcc dot gnu.org
2021-12-14 22:11 ` [Bug middle-end/103720] " pinskia at gcc dot gnu.org
2021-12-14 22:53 ` [Bug tree-optimization/103720] " qinzhao at gcc dot gnu.org
2022-01-12 15:53 ` qinzhao at gcc dot gnu.org
2022-01-12 15:54 ` qinzhao 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).