This is the mail archive of the gcc-bugs@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]

optimization/3520: Spurious warning with -Wunreachable-code



>Number:         3520
>Category:       optimization
>Synopsis:       Spurious warning with -Wunreachable-code
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          mistaken
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 01 15:36:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     jwm@csua.berkeley.edu
>Release:        gcc-3.0
>Organization:
>Environment:

>Description:
I believe this is related to 3408, BUt I couldn't update that 
issue and I wasn't sure if they were the same.

As shown below, I get a warning on a break that really needs to be there ans hould in fact be reached.
Using either the abort() or call with return, or even no call w/ 
just the return in the default case I get the message.  I have tried to 
reduce this is teh most Minimal example that I can.  -O2 or higher is required
and with C++ -fno-exceptions is. 

>How-To-Repeat:
Viper> cat test_gcc.c

void abort (void)  __attribute__((__noreturn__));

void int_dispatch(int, void *);
void recover(void *); 

void Dispatch(int level, void *ch, int type)
{
  switch (type) {
  case 0:
  case 2:
    int_dispatch(level, ch);
    break;
  default :
        // This can contain Either the return or the abort()
        abort();
//    recover(ch);
//    return;
  }
}

Viper> gcc-3.0 -Wunreachable-code -O2 -S test_gcc.c             
test_gcc.c: In function `Dispatch':
test_gcc.c:13: warning: will never be executed
Viper> g++-3.0 -fno-exceptions -Wunreachable-code -O2 -S test_gcc.c
test_gcc.c: In function `void Dispatch(int, void*, int)':
test_gcc.c:13: warning: will never be executed
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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