Spurious warning in gcc SVN trunk

Kevin P. Fleming kpfleming@digium.com
Wed Aug 12 06:04:00 GMT 2009

Ian Lance Taylor wrote:
> "Kevin P. Fleming" <kpfleming@digium.com> writes:
>> Compiling this as follows:
>>> $ ~/gcc-trunk/bin/gcc -o test test.c -Wall
>>> test.c: In function ‘main’:
>>> test.c:23:4: warning: jump skips variable initialization
>>> test.c:11:2: note: label ‘TEST_LABEL’ defined here
>>> test.c:9:9: note: ‘foo’ declared here
>> While this warning is completely accurate, it's also spurious, because
>> the code that will execute after the jump to TEST_LABEL does not
>> reference the local variable 'foo' in the target block at all.
>> Now, I don't expect anyone to like this code... I've already fixed it up
>> to not be so horrifically bad, but it's still perfectly valid and should
>> not generate such a warning. Comments?
> This was the subject of a long discussion over on gcc@gcc.gnu.org, which
> ended here:
> http://gcc.gnu.org/ml/gcc/2009-06/msg00704.html
> If you have something new to contribute, please do.

Well... in my case, this warning caught one real bug (a variable whose
initialization was skipped could have been referenced after the jump)
and one non-bug (the only possible code path after the jump did not
reference the variable in question at all). So, based on that, I'm fine
with both the warning being added and it being part of -Wall, but it'd
be great if somehow it could be extended to use the same information
that -Wuninitialized does to determine whether the variable in question
could, in fact, actually be referenced after the jump or not.

Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
skype: kpfleming | jabber: kpfleming@digium.com
Check us out at www.digium.com & www.asterisk.org

More information about the Gcc-help mailing list