Title
Union members with user-declared non-default constructors
Status
nad
Section
11.5 [class.union]
Submitter
Alisdair Meredith

Created on 2005-03-19.00:00:00 last changed 160 months ago

Messages

Date: 2011-08-15.00:00:00

Rationale (August, 2011):

As given in the preceding note.

Date: 2008-03-15.00:00:00

Note (March, 2008):

This issue was resolved by the adoption of paper J16/08-0054 = WG21 N2544 (“Unrestricted Unions”) at the Bellevue meeting.

Date: 2022-11-20.07:54:16

Can a member of a union be of a class that has a user-declared non-default constructor? The restrictions on union membership in 11.5 [class.union] paragraph 1 only mention default and copy constructors:

An object of a class with a non-trivial default constructor (11.4.5 [class.ctor]), a non-trivial copy constructor (11.4.5.3 [class.copy.ctor]), a non-trivial destructor (11.4.7 [class.dtor]), or a non-trivial copy assignment operator (12.4.3.2 [over.ass], 11.4.5.3 [class.copy.ctor]) cannot be a member of a union...

(11.4.5 [class.ctor] paragraph 11 does say, “a non-trivial constructor,” but it's not clear whether that was intended to refer only to default and copy constructors or to any user-declared constructor. For example, 6.7.7 [class.temporary] paragraph 3 also speaks of a “non-trivial constructor,” but the cross-references there make it clear that only default and copy constructors are in view.)

History
Date User Action Args
2011-09-06 00:00:00adminsetmessages: + msg3579
2011-09-06 00:00:00adminsetstatus: review -> nad
2008-03-17 00:00:00adminsetmessages: + msg1602
2008-03-17 00:00:00adminsetstatus: open -> review
2005-03-19 00:00:00admincreate