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

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).