Why do I receive a warning for this code ?
switch(iInput)
{
...
case 1I64<<31: return 31; break;
...
}
1>C:\path-to-file.cpp(44) : warning C4309: ‘case’ : truncation of constant value
1I64<<31 is 0x0000000080000000 (__int64) so no truncation here,
it’s there a maximum value for case ?
The type of the expression controlling the
switchcontrols they type of the expression thecaselabels will use.You’ll need an
__int64(or equivalent) type in the controlling expression to get rid of the warning.