This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: -Wswitch vs -Wuninitialized


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~

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]