4 ms·
Do you mean when specific flags are passed to the compiler? I wasn’t aware of that. C++ has defined behavior for non-exhaustive switch statements, just like a n
by todd8 5y ago
Do you mean when specific flags are passed to the compiler? I wasn’t aware of that. C++ has defined behavior for non-exhaustive switch statements, just like a non-exhaustive if statement (that is an if statement missing an else clause).
- ahartmetz 5y agoCompilers have (optional - it's kinda good practice to enable them though) warnings about things that are perfectly within spec and not undefined behavior, but usually a bad idea. A switch statement with a default: label is exhaustive. The warning is only about switches without a default. There is also a warning about exhaustive switches with a default. Makes sense - the first is apparently supposed to handle all the cases, but doesn't. The second is apparently supposed to handle some cases and not some others, but given that it's actually exhaustive, any enumerator added later should probably get its own label instead of falling under the previously unused default label.