5.19: A converted constant expression of type T is a literal constant expression, implicitly converted to type T, where the implicit conversion (if any) is permitted in a literal constant expression and the implicit conversion sequence contains only user-defined conversions, lvalue-to-rvalue conversions (4.1), integral promotions (4.5), and integral conversions (4.7) other than narrowing conversions (8.5.4). [ Note: such expressions may be used as case expressions (6.4.2), .... So a floating point literal is not a valid case expression, since converting it to the switch type would require a non-integral conversion. void f(int i) { switch (i) { case 1.0:; } }
*** Bug 52257 has been marked as a duplicate of this bug. ***
Jason, I'm thinking that this should be doable rather easily by adding a new LOOKUP_NO_NON_INTEGRAL mask and passing it down to standard_conversion from case_conversion via perform_implicit_conversion_flags. Then standard_conversion can exclude all such non-integral conversions, eg, for this specific testcase, return NULL from line #1332 because fcode == REALTYPE && (flags & LOOKUP_NO_NON_INTEGRAL)). Makes sense?
Mine.
Fixed for 4.9.0.