Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 10.3 Does exception 1 apply to case labels?
#1
Rule 10.3 covers assignment (as defined in the glossary) and the conversion of the constant expression in case labels.

Exception 1 says "A non-negative integer constant expression of essentially signed type may be assigned to an object of essentially unsigned type if its value can be represented in that type."

Is this exception intended to be restricted to assignment; or does it also apply to case labels?

Code:
switch (u8a) // controlling expression is essentially unsigned
{
    case 1: break; // '1' is essentially signed; 10.3 violation?
    case 2: break;
    default: break;
}
<t></t>


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)