Re: Enable -Wswitch-enum? [was Re: MOZ_ASSUME_UNREACHABLE is being misused]

2014-04-07 Thread ISHIKAWA,chiaki
(2014/04/07 14:27), Karl Tomlinson wrote: It is allowed in N3242. I think the relevant sections are 5.2.9 Static cast Thank you for the pointer. I found a floating copy of n3242.pdf at the following url. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf I think 7.2 10 is

Re: Enable -Wswitch-enum? [was Re: MOZ_ASSUME_UNREACHABLE is being misused]

2014-04-07 Thread Karl Tomlinson
chiaki ISHIKAWA writes: I think 7.2 10 is also relevant here. --- quote --- An expression of arithmetic or enumeration type can be converted to an enumeration type explicitly. The value is unchanged if it is in the range of enumeration values of the enumeration type; otherwise the

Re: Enable -Wswitch-enum? [was Re: MOZ_ASSUME_UNREACHABLE is being misused]

2014-04-07 Thread Zack Weinberg
On 2014-04-07 6:00 AM, Karl Tomlinson wrote: chiaki ISHIKAWA writes: I think 7.2 10 is also relevant here. --- quote --- An expression of arithmetic or enumeration type can be converted to an enumeration type explicitly. The value is unchanged if it is in the range of enumeration values of

Re: Enable -Wswitch-enum? [was Re: MOZ_ASSUME_UNREACHABLE is being misused]

2014-04-06 Thread Karl Tomlinson
On Fri, 04 Apr 2014 11:03:57 -0400, Zack Weinberg wrote: On Tue, Apr 1, 2014 at 10:13 PM, Karl Tomlinson mozn...@karlt.net wrote: Does WARNINGS_AS_ERRORS make the default:MOZ_CRASH() unnecessary? No, because it's possible that the thing you're testing is not actually a valid enum value,

Re: Enable -Wswitch-enum? [was Re: MOZ_ASSUME_UNREACHABLE is being misused]

2014-04-06 Thread ISHIKAWA,chiaki
(2014/04/07 10:16), Karl Tomlinson wrote: because enumeration types may hold values that don't match any of their enumerator values. Is this allowed by C (or C++) specification today? [Yes, I know the compiler in the past did not care much.] I thought the stricter warnings of compilers today

Re: Enable -Wswitch-enum? [was Re: MOZ_ASSUME_UNREACHABLE is being misused]

2014-04-06 Thread Karl Tomlinson
chiaki ISHIKAWA writes: (2014/04/07 10:16), Karl Tomlinson wrote: because enumeration types may hold values that don't match any of their enumerator values. Is this allowed by C (or C++) specification today? It is allowed in N3242. I think the relevant sections are 5.2.9 Static cast 10 A

Re: Enable -Wswitch-enum? [was Re: MOZ_ASSUME_UNREACHABLE is being misused]

2014-04-04 Thread Zack Weinberg
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 On 04/02/2014 07:37 AM, Aryeh Gregor wrote: On Tue, Apr 1, 2014 at 5:56 PM, Zack Weinberg za...@panix.com wrote: The downside of turning this on would be that any switch statements that *deliberately* include only a subset of the enumerators,

Re: Enable -Wswitch-enum? [was Re: MOZ_ASSUME_UNREACHABLE is being misused]

2014-04-02 Thread Aryeh Gregor
On Tue, Apr 1, 2014 at 5:56 PM, Zack Weinberg za...@panix.com wrote: The downside of turning this on would be that any switch statements that *deliberately* include only a subset of the enumerators, plus a default case, would now have to be expanded to cover all the enumerators. If there are

Re: Enable -Wswitch-enum? [was Re: MOZ_ASSUME_UNREACHABLE is being misused]

2014-04-01 Thread Daniel Holbert
On 04/01/2014 08:56 AM, Zack Weinberg wrote: The downside of turning this on would be that any switch statements that *deliberately* include only a subset of the enumerators, plus a default case, would now have to be expanded to cover all the enumerators. I would try it and report on how

Re: Enable -Wswitch-enum? [was Re: MOZ_ASSUME_UNREACHABLE is being misused]

2014-04-01 Thread Karl Tomlinson
Zack Weinberg writes: This is a bit of a tangent, but: There are a whole bunch of places in layout, and probably elsewhere, where we have the following catch-22: if you have a switch statement over the values of an enumeration, gcc and clang (with -Wall) will warn you about enumeration values

Re: Enable -Wswitch-enum? [was Re: MOZ_ASSUME_UNREACHABLE is being misused]

2014-04-01 Thread Chris Peterson
On 4/1/14, 10:22 AM, Daniel Holbert wrote: So, we have on the order of ~4400 switch statements that would potentially need expanding to avoid tripping this warning. clang on OS X reports 1635 -Wswitch-enum warnings (switch on enum not handling all enum cases). gcc reports 1048