This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/10515: g++ 3.3 mixes up types when an initialized field in a union is notthe first one
- From: Andreas Oberritter <obi at saftware dot de>
- To: gcc-gnats at gcc dot gnu dot org
- Cc: debian-gcc at lists dot debian dot org
- Date: 27 Apr 2003 19:30:27 +0200
- Subject: c++/10515: g++ 3.3 mixes up types when an initialized field in a union is notthe first one
>Number: 10515
>Category: c++
>Synopsis: g++ 3.3 mixes up types when an initialized field in a union
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Sun Apr 27 17:36:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Andreas Oberritter
>Release: 3.3 20030415 (Debian prerelease) (Debian testing/unstable)
>Organization:
>Environment:
System: Linux shiva 2.4.20-ac2 #1 Sun Jan 5 10:47:07 CET 2003 i686
unknown unknown GNU/Linux
Architecture: i686
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared
--with-system-zlib --enable-nls --without-included-gettext
--enable-__cxa_atexit --enable-clocale=gnu --enable-debug
--enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc
i386-linux
>Description:
g++ 3.3 treats members of a union as if they were of the
first member's type. g++ 3.2 and gcc 3.3 can compile it.
>How-To-Repeat:
struct a {
int x;
};
struct b {
int x;
int y;
};
struct foo {
union {
struct a a;
struct b b;
} u;
};
int main(void)
{
struct foo bar = { u: { b: { x: 0, y: 0, }}};
(void)bar;
return 0;
}
$ CXXFLAGS="" CPPFLAGS="" g++-3.3 union_bug.cpp -o union_bug
union_bug.cpp: In function `int main()':
union_bug.cpp:20: error: too many initializers for `a'
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
is not the first one