This is the mail archive of the
mailing list for the GCC project.
Re: -Wswitch vs -Wuninitialized
- To: Andrew Cagney <ac131313 at cygnus dot com>
- Subject: Re: -Wswitch vs -Wuninitialized
- From: Richard Henderson <rth at redhat dot com>
- Date: Mon, 20 Nov 2000 11:24:36 -0800
- Cc: gcc at gcc dot gnu dot org
- References: <3A18A3C0.7D154E0B@cygnus.com>
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.