I have a piece of code that compiles fine when I write it in this form (with the -Wjump-misses-init
flag):
int some_function(void) {
...
if (is_error)
goto error;
int a;
a = 1;
return a;
error:
return 666;
}
But when I write the same function in this form I get the below warning when I compile (:
int some_function(void) {
...
if (is_error)
goto error;
int a = 1;
return a;
error:
return 666;
}
test.c: In function 'some_function':
test.c:15:17: warning: jump skips variable initialization [-Wjump-misses-init]
test.c:21:1: note: label 'error' defined here
test.c:17:13: note: 'a' declared here
Why does GCC give me that warning when I declare and initialize a
on the same line? Seems a bit odd to me? These examples are nonsensical but I'm afraid I'm not at liberty to divulge the real code snippet. I am running GCC 4.7.2 on Debian Wheezy 7.3.
EDIT: void typo