This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: c/8828: [3.2/3.3/3.4 regression] gcc reports some code isunreachable when it is not
- From: Steven Bosscher <s dot bosscher at student dot tudelft dot nl>
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 15 Feb 2003 20:06:00 -0000
- Subject: Re: c/8828: [3.2/3.3/3.4 regression] gcc reports some code isunreachable when it is not
- Reply-to: Steven Bosscher <s dot bosscher at student dot tudelft dot nl>
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? */