------- Comment #2 from rguenth at gcc dot gnu dot org 2008-02-04 17:04 ------- The warning persists for me on the trunk, and the initialization is not done:
main (c, v) { int D.2713; int D.2714; int j[3]; typedef struct { int c; int * j; union pthread_mutex_t m; } struct struct { int c; int * j; union pthread_mutex_t m; }; struct { int c; int * j; union pthread_mutex_t m; } r; r.j = &j; r.m.__data.__lock = 0; r.m.__data.__count = 0; r.m.__data.__owner = 0; r.m.__data.__nusers = 0; r.m.__data.__kind = 0; r.m.__data.__spins = 0; r.m.__data.__list.__prev = 0B; r.m.__data.__list.__next = 0B; D.2713 = r.c; printf (&"current should be zero but is %d\n"[0], D.2713); D.2714 = 0; return D.2714; } This worked in 4.0.3 and 4.1.1 which generated r = {}; r.j = &j; D.1158 = r.c; So, this is likely a middle-end/gimplification issue (again). "Reduced" testcase: typedef struct __pthread_internal_list { void *__prev; void *__next; } __pthread_list_t; typedef union { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; int __spins; __pthread_list_t __list; } __data; char __size[40]; long int __align; } pthread_mutex_t; extern int printf (__const char *__restrict __format, ...); int main(int c, char **v) { int j[3]; struct { int c, *j; pthread_mutex_t m; } r = { .j = j, .m = { { 0, 0, 0, 0, 0, 0, { 0, 0 } } }, }; printf("current should be zero but is %d\n", r.c); return 0; } -- rguenth at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Component|c |middle-end Ever Confirmed|0 |1 Known to fail| |4.0.4 4.1.2 4.2.0 4.2.3 | |4.3.0 Known to work| |4.0.3 4.1.1 Last reconfirmed|0000-00-00 00:00:00 |2008-02-04 17:04:08 date| | Summary|auto structure not |[4.1/4.2/4.3 Regression] |initialized correctly |auto structure not | |initialized correctly Target Milestone|--- |4.1.3 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33631