[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] fix jump-misses-init warnings

From: Ken Raeburn
Subject: Re: [PATCH] fix jump-misses-init warnings
Date: Mon, 14 Sep 2009 04:21:14 -0400

On Sep 14, 2009, at 03:37, Ludovic Courtès wrote:
Why does it help to move locals to the enclosing scope? I’d expect the

Jumping over the initializer is a simpler analysis than used-before- set. It may also yield different results, if the "goto" that branches into the block and bypasses the initializer can now be reached through a path that retains a value of the variable in question stored by a previous pass through that block entering at the top. You could still warn "possibly used before set", unless that's the only way to get to that goto statement.

If the logic of the function requires recalculating the value on any entry to the block, moving the declaration to an outer block is just masking the bug, not fixing it.

In this case, though, nothing after the label uses the value of the variable for which the initialization is bypassed, so it seems okay. Though, I'd think the declaration could be left in the same scope, and just split into a declaration without initializer and a separate assignment statement; that would probably suppress the warning without triggering a used-before-set warning, and wouldn't require renaming all the other "n" variables. (If it doesn't, I think it might be a smaller change to rename the variable for which the declaration is being moved, rather than all the others.)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]