False positive warning: missing return statement and switch statements

Frans Englich frans.englich@telia.com
Tue Nov 15 22:40:00 GMT 2005


On Tuesday 15 November 2005 22:26, Steven L. Zook wrote:
> What happens when someone calls with:
>
> toInt( (Number)3 );
>
> C/C++ lets you cast any numeric to an enum.

Indeed. I think it's easy to deliberately break code which gcc doesn't warn 
for. If the programmer decides to by pass static type checking and (ab)use an 
enumerator by not using it for what it is but as a plain integer -- then I 
expect it to break(no return value at runtime). After all, if one want 
arbitrary integers: then use an integer, not an enum.

As I see it, the whole point with enumerators is static type checking safety. 
The warning counter-acts this by giving false positives for those who use 
enumerators properly(that is, they don't store arbitrary integers in them).

Obviously, I am looking at this the wrong way -- please explain.


Cheers,

		Frans



More information about the Gcc-help mailing list