This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/46045] incorrect code generated if redecalring local variable in do-while(0)


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46045

Zdenek Sojka <zsojka at seznam dot cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |zsojka at seznam dot cz

--- Comment #1 from Zdenek Sojka <zsojka at seznam dot cz> 2010-10-16 13:31:58 UTC ---
> struct A *a = a;

Refers to the just declared variable, thus the variable is initialised by
itself.

$ gcc-4.6.0-pre9999 test.c -Wall -W -Wshadow -Winit-self
test.c: In function 'foo':
test.c:9:27: warning: declaration of 'a' shadows a parameter [-Wshadow]
test.c:6:27: warning: shadowed declaration is here [-Wshadow]
test.c:6:27: warning: unused parameter 'a' [-Wunused-parameter]
test.c: In function 'main':
test.c:14:14: warning: unused parameter 'argc' [-Wunused-parameter]
test.c:14:26: warning: unused parameter 'argv' [-Wunused-parameter]
test.c: In function 'foo':
test.c:9:27: warning: 'a' is used uninitialized in this function
[-Wuninitialized]

You get the warning with -Winit-self -Wuninitialized


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]