http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45977
Thadeu Lima de Souza Cascardo <cascardo at holoscopio dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |cascardo at holoscopio dot | |com --- Comment #4 from Thadeu Lima de Souza Cascardo <cascardo at holoscopio dot com> 2011-05-09 03:49:25 UTC --- What seemed really strange to me is that the warning would be emitted even when the static declaration was inside #if 0/#endif pair, since the pre-processor would have removed the code entirely. And reading the warning also told me the problem was assigning a value in the extern declaration. So extern int i = 3; is not fine. While static int i = 3; extern int i; is perfectly OK. That is, without any warning on/off flags, there is no warning. Should there be such a warning as Joseph says? -Wall -Wextra emits no warning for static int i; extern int i; case. In fact, there is -Wredundant-decls, but it only works if there is no initialization in the extern declaration. I can turn off this warning using -w, but there is no particular flag for this warning. Should one of the existing flags be used or a new one be created? Better yet, should gcc not warn when this initialization happens in this particular case, when the variable has already been declared as static?