Why doesn't gcc allow a const int as a case expression?
A constant expression is not the same as a const-qualified type value, even though technically the value is known by the compiler at the point of the case
statement.
Imagine what would happen if another file declared extern const int FOO
and tried to use it the same way. The compiler wouldn't know what FOO
was because it was defined in another file. Even though it has a constant value, it is not a constant expression.