[LLVMbugs] [Bug 7359] New: 'spurious "switch condition has bool value" warning'

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jun 11 10:26:30 PDT 2010


           Summary: 'spurious "switch condition has bool value" warning'
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: greearb at candelatech.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com

#include <iostream>

#ifndef static_assert
#define static_assert(a) switch ((int)(a)) case 0: case ((int)(a)):
#endif /* static_assert */

int main() {

   static_assert(sizeof(int) == sizeof(unsigned int));
   return 0;

[greearb at grok2 ~]$ clang++ -Os clang_test2.cc 
clang_test2.cc:10:4: warning: switch condition has boolean value
   static_assert(sizeof(int) == sizeof(unsigned int));
clang_test2.cc:5:26: note: instantiated from:
#define static_assert(a) switch ((int)(a)) case 0: case ((int)(a)):
                         ^       ~~~~~~~~
1 warning generated.
[greearb at grok2 ~]$

// This is a work-around:
//#define static_assert(a) switch ((a) + 0) case 0: case ((a) + 0):

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