[LLVMbugs] [Bug 13815] New: -Wunreachable-code cannot be silenced for default cases in switches
    bugzilla-daemon at llvm.org 
    bugzilla-daemon at llvm.org
       
    Tue Sep 11 08:21:06 PDT 2012
    
    
  
http://llvm.org/bugs/show_bug.cgi?id=13815
             Bug #: 13815
           Summary: -Wunreachable-code cannot be silenced for default
                    cases in switches
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: magnus.reftel at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified
The flag -Wcovered-switch-default enables warnings for default cases in
switches that cannot be reached, e.g. because all possible enum values have
been listed. For code where the defaults are added intentionally, the
-Wno-covered-switch-default can be used to silence the warning. However,
-Wunreachable-code also enables warnings for the same cases, but they cannot be
silenced without -Wno-unreachable-code, which disables all unreachable code
warnings.
Code snipped illustrating the behaviour follows.
#include <stdlib.h>
enum e {E1, E2};
int main(int argc, char* argv[])
{
        enum e e = atoi(argv[argc-1]);
        switch(e)
        {
                case E1: return 1;
                case E2: return 2;
/* Both -Wcovered-switch-default and -Wunreachable-code trigger below */
                default: return 3; 
        }
}
-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
    
    
More information about the llvm-bugs
mailing list