This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
constructors in unions
- From: Andrew Haley <aph at redhat dot com>
- To: Corn Hulio <nitrogenycs at firemail dot de>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 4 Dec 2003 18:50:25 +0000
- Subject: constructors in unions
- References: <oprzn6v7w6htpmjh@mail.firemail.de>
Corn Hulio writes:
> Hello,
>
> why isn't the following contruct possible?
>
> union
> {
> Vector<float,3> pos;
>
> struct
> {
> float x, y, z;
> };
>
> float p[3];
> };
>
> GCC gives me this error:
> member `Vector<float, 3> <anonymous union>::pos' with constructor not
> allowed in union
>
> I guess in theory there should be no reason to disallow a member with
> constructor in a union (as long as there is not more than 1 constructor).
12.1, Para 12, Constructors: A union member shall not be of a class
type (or array thereof) that has a non-trivial constructor.