[cfe-dev] why do i get the "c++11-narrowing" warning only in switch	using defines?
    Dennis Luehring 
    dl.soluz at gmx.net
       
    Mon May 11 02:23:18 PDT 2015
    
    
  
#define TEST0 0xFFFA0000
#define TEST1 0xFFFA0001
const int test0 = 0xFFFA0000;
const int test1 = 0xFFFA0001;
int main(int argc, char** arcv)
{
   if(argc == TEST0) // OK
   {
     return 1;
   }
   if(argc == test0) // OK
   {
     return 1;
   }
   switch(argc)
   {
     case TEST1: return 2; // ERROR: case value evaluates to 4294574081, 
which cannot be narrowed to type 'int' [-Wc++11-narrowing]
   }
   switch(argc)
   {
     case test1: return 2; // OK
   }
}
    
    
More information about the cfe-dev
mailing list