我发现,有些法典编纂成克温堡,但不是部族:
#include<stdio.h>
int main(int argc, char **argv) {
int test = 0;
if (test == 0) {
goto print_five;
} else {
return 0;
}
print_five:
int five = 6;
printf("value of five: %d
", five);
return 0;
}
if I declare the variable five
to the top of the function (under test
),
then the program compiles under both compilers.
After reading questions [1] and [2], I thought maybe it had to do with potentially skipping a variable declaration, similar to needing to create scope in case statements. The following examples compile in both compilers as well.
print_five:
printf("value of five: ");
int five = 6;
printf("%d
", five);
return 0;
print_five: ;
int five = 6;
printf("value of five: %d
", five);
return 0;
however it seems that this isn t the case, and has to do with having an expression directly after a label. But isn t variable declaration/initialization considered an expression? Is there something wrong with my first example, or does clang have a bug?