This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c/8828: [3.2/3.3/3.4 regression] gcc reports some code isunreachable when it is not


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?  */
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]