This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

constructors in unions


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.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]