-Wswitch vs -Wuninitialized
Richard Henderson
rth@redhat.com
Mon Nov 20 11:24:00 GMT 2000
On Mon, Nov 20, 2000 at 03:08:32PM +1100, Andrew Cagney wrote:
> Adding the missing enum vis:
> still gives the warning:
>
> `i' might be used uninitialized in this function
The problem being that "ev" might have a value outside the enumeration.
So -Wswitch is trying to ensure that you havn't forgotten something,
but -Wuninitialized is traversing the CFG and determining that there
is a path that results in an uninitialized use.
> Alternativly, is there a suggested coding pratice that addreses this?
GCC typically adds "default: abort()" to most switches like that.
r~
More information about the Gcc
mailing list