public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/102276] New: -ftrivial-auto-var-init fails to initialize a variable, causes a spurious warning
@ 2021-09-10 14:17 amonakov at gcc dot gnu.org
  2021-09-13 10:14 ` [Bug middle-end/102276] " rguenth at gcc dot gnu.org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: amonakov at gcc dot gnu.org @ 2021-09-10 14:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102276

            Bug ID: 102276
           Summary: -ftrivial-auto-var-init fails to initialize a
                    variable, causes a spurious warning
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amonakov at gcc dot gnu.org
  Target Milestone: ---

int g(int *);
int f1()
{
    switch (0) {
        int x;
        default:
        return g(&x);
    }
}
int f2()
{
    goto L;
    {
        int x;
        L:
        return g(&x);
    }
}

Compiling with -O2 -ftrivial-auto-var-init=pattern causes spurious

warning: statement will never be executed [-Wswitch-unreachable]
    5 |         int x;
      |             ^


In both f1 and f2, resulting assembly does not in fact initialize 'x':

f1:
        subq    $24, %rsp
        leaq    12(%rsp), %rdi
        call    g
        addq    $24, %rsp
        ret
f2:
        subq    $24, %rsp
        leaq    12(%rsp), %rdi
        call    g
        addq    $24, %rsp
        ret

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-03-02 16:56 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-10 14:17 [Bug middle-end/102276] New: -ftrivial-auto-var-init fails to initialize a variable, causes a spurious warning amonakov at gcc dot gnu.org
2021-09-13 10:14 ` [Bug middle-end/102276] " rguenth at gcc dot gnu.org
2021-09-13 17:50 ` amonakov at gcc dot gnu.org
2021-09-14 17:55 ` kees at outflux dot net
2022-02-12 18:14 ` kees at outflux dot net
2022-02-12 20:22 ` pinskia at gcc dot gnu.org
2022-02-14  7:26 ` rguenth at gcc dot gnu.org
2022-02-14 16:08 ` jakub at gcc dot gnu.org
2022-02-14 17:02 ` qinzhao at gcc dot gnu.org
2022-02-14 23:21 ` qinzhao at gcc dot gnu.org
2022-02-15  8:16 ` rguenther at suse dot de
2022-02-15 16:02 ` qinzhao at gcc dot gnu.org
2022-02-15 19:55 ` qinzhao at gcc dot gnu.org
2022-02-17  7:22 ` rguenther at suse dot de
2022-02-17 19:57 ` qinzhao at gcc dot gnu.org
2022-03-02 16:55 ` cvs-commit at gcc dot gnu.org
2022-03-02 16:56 ` 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).