public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Steven Bosscher <s.bosscher@student.tudelft.nl> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: c/8828: [3.2/3.3/3.4 regression] gcc reports some code is unreachable when it is not Date: Sat, 15 Feb 2003 20:06:00 -0000 [thread overview] Message-ID: <20030215200600.9845.qmail@sources.redhat.com> (raw) The following reply was made to PR c/8828; it has been noted by GNATS. From: Steven Bosscher <s.bosscher@student.tudelft.nl> To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, rcampbell@tropicnetworks.com, nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org Cc: Subject: Re: c/8828: [3.2/3.3/3.4 regression] gcc reports some code is unreachable when it is not Date: 15 Feb 2003 20:56:34 +0100 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8828 We would incorrectly flag the case blocks as unreachable code (with -Wunreachable-code, or course) for this testcase: void foo (int i) { switch (i) { case 0: break; case 1: break; }; }; The problem seems to be that in the loop in jump.c:never_reached_warning() ignores barriers, so it happily falls through to the next basic block and thinks that the jump_insn for break is an unreachable insn. With the attached patch, we terminate the loop when we hit a barrier. I hardly tested this patch, but I've made sure that it bootstraps, fixes the testcase and does not break any of the test cases in the test suite that have the option "-Wunreachable-code". I can't do a full regression test (just a bootstrap takes about half a day on my computer :-/), and it wouldn't even matter for the bootstrap because -Wunreachable-code is not set for "-Wall". There's also another change in behavior; for this test case: int x; void foo (int i) { switch (i) { case 0: startfor: goto caseend; x = 1; case 1: x = 1; break; } caseend: return; } We used to flag that the "goto caseend;" was unreachable code, instead of "x=1". I think this is actually an example of this PR (8828), not warning about "x = 1" is probably the same bug as reported in PR c/5897. With this patch we don't have a warning for this code at all. I think this still is better than having false positives. Can somebody with a better machine give this patch some propper testing? Greetz Steven Index: gcc/jump.c =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/jump.c,v retrieving revision 1.216 diff -c -3 -p -r1.216 jump.c *** gcc/jump.c 10 Jan 2003 13:44:28 -0000 1.216 --- gcc/jump.c 15 Feb 2003 19:16:48 -0000 *************** never_reached_warning (avoided_insn, fin *** 1918,1924 **** for (insn = avoided_insn; insn != NULL; insn = NEXT_INSN (insn)) { ! if (finish == NULL && GET_CODE (insn) == CODE_LABEL) break; if (GET_CODE (insn) == NOTE /* A line number note? */ --- 1918,1925 ---- for (insn = avoided_insn; insn != NULL; insn = NEXT_INSN (insn)) { ! if ((finish == NULL && GET_CODE (insn) == CODE_LABEL) ! || GET_CODE (insn) == BARRIER) break; if (GET_CODE (insn) == NOTE /* A line number note? */
next reply other threads:[~2003-02-15 20:06 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-02-15 20:06 Steven Bosscher [this message] 2003-02-20 9:36 Steven Bosscher 2003-02-22 5:44 aj
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=20030215200600.9845.qmail@sources.redhat.com \ --to=s.bosscher@student.tudelft.nl \ --cc=gcc-prs@gcc.gnu.org \ --cc=nobody@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).