This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/52880] New: -Woverride-init emitts unexpected error
- From: "eparis at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 05 Apr 2012 18:44:29 +0000
- Subject: [Bug c/52880] New: -Woverride-init emitts unexpected error
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: eparis@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