http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52880
Bug #: 52880
Summary: -Woverride-init emitts unexpected error
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: epa...@redhat.com
struct s1 {
int s1i;
int s1j;
};
struct s2 {
struct s1 s1;
int s2x;
int s2y;
};
int main(void)
{
struct s2 s2 = {
.s1.s1i= 0,
.s2y= 1,
.s2x= 2,
.s1.s1j= 3,
};
return 0;
}
$ gcc -o /tmp/tmp /tmp/tmp.c -Woverride-init
/tmp/tmp.c: In function ‘main’:
/tmp/tmp.c:18:3: warning: initialized field overwritten [-Woverride-init]
/tmp/tmp.c:18:3: warning: (near initialization for ‘s2’) [-Woverride-init]
If you twiddle any of the testcase, it doesn't complain. switching the order
you initialize s2x and s2y causes it to not complain. If you want to get 2
warnings you can declare s1 between s2x and s2y.
I see this on both:
gcc-4.7.0-1.fc17.x86_64
gcc-4.4.6-4.el6.x86_64