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

Compiler warnings for compile time constants in inactive branches


Hi

What is the best way to get rid of warnings which GCC spuriously raises for inactive code branches, like in the following example?

const int c = 33;
int result =  (c < 32) ? (1 << c) : 0;
// previous line raises "left shift count >= width of type" warning

In Visual Studio I would just selectively deactivate the warnings around the affected code area.
Altenatively I could use an ugly fix like
int result = (c < 32) ? (1 << c*(c < 32)) : 0;
or branch out the code in separate template specializations. Is there any better way to do this in GCC?


Regards,
  Stephan




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