This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/37476] New: Initialising a union member of a struct without braces
- From: "stl at koffein dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Sep 2008 09:37:46 -0000
- Subject: [Bug c/37476] New: Initialising a union member of a struct without braces
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Compiling:
typedef struct t {
char *d;
union {
int aa;
float ab;
} a;
} T;
int f() {
T s = {"one", 1};
return s.a.aa;
}
with -Wall --std=c99 yields:
structinit.c: In function 'f':
structinit.c:10: warning: missing braces around initializer
structinit.c:10: warning: (near initialization for 's.a')
However, my understanding of C99[/TC3] section 6.7.8, point 17 and in
particular footnote 129 suggests that this initialisation is quite valid.
(Tested here against gcc version 4.2.1 20070719 [FreeBSD]; 3.2.3 on redhat
produced the same warning.)
--
Summary: Initialising a union member of a struct without braces
Product: gcc
Version: 4.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: stl at koffein dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37476