
On Fri, 4 Jan 2013, Stefan Seyfried wrote:
Am 03.01.2013 12:47, schrieb Josef Reidinger:
Better fix the compiler to not spew unnecessary warnings.
Well, thats really bad practice. If you want to do it with switch, then there should be something like default: assert(false, "Unknown statement"); //or log or anything that shout loudly enough to notice that there is problem when extending software return NULL;
Reason is, that when you extend program, you should be warned if you forget to modify some use case. In C it is more tricky, as it is not C++ and enum is just constant definition, so it is not easy to check other integer can come to it.
I certainly agree that this piece of code is ugly as hell and probably crap.
Anyway, the function that generates the value for the switch statement can only return 3 different values, and all of those are handled in the switch. So the compiler *is* wrong in this case. Even if the code is ugly.
The compiler is not wrong - there is no return. The conclusion drawn from the compiler message, that the program is necessarily buggy, is wrong. Richard. -- Richard Biener <rguenther@suse.de> SUSE / SUSE Labs SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 GF: Jeff Hawn, Jennifer Guild, Felix Imend -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org