Title
Specifications that should apply only to non-static union data members
Status
cd2
Section
11.5 [class.union]
Submitter
Mike Miller

Created on 2008-09-17.00:00:00 last changed 178 months ago

Messages

Date: 2009-07-15.00:00:00

[Voted into WP at July, 2009 meeting.]

Date: 2009-03-15.00:00:00

Proposed resolution (March, 2009):

  1. Change the footnote in 6.8.5 [basic.type.qualifier] paragraph 1 as follows:

  2. The same representation and alignment requirements are meant to imply interchangeability as arguments to functions, return values from functions, and non-static data members of unions.
  3. Change 7.2.1 [basic.lval] bullet 15.6 as follows:

    • an aggregate or union type that includes one of the aforementioned types among its elements or non-static data members (including, recursively, a an element or non-static data member of a subaggregate or contained union),
  4. Change 7.6.9 [expr.rel] bullet 2.5 as follows:

    • If two pointers point to non-static data members of the same union object, they compare equal (after conversion to void*, if necessary)...
  5. Change 9.12.2 [dcl.align] paragraph 8 as follows:

  6. [Note: the alignment of a union type can be strengthened by applying the alignment attribute to any non-static data member of the union. —end note]
  7. Change 9.4.2 [dcl.init.aggr] paragraph 15 as follows:

  8. When a union is initialized with a brace-enclosed initializer, the braces shall only contain an initializer-clause for the first non-static data member of the union...
  9. Change 11.5 [class.union] paragraph 1 as follows:

  10. In a union, at most one of the non-static data members can be active at any time, that is, the value of at most one of the non-static data members can be stored in a union at any time. [Note: one special guarantee is made in order to simplify the use of unions: If a standard-layout union contains several standard-layout structs that share a common initial sequence (11.4 [class.mem]), and if an object of this standard-layout union type contains one of the standard-layout structs, it is permitted to inspect the common initial sequence of any of standard-layout struct members; see 11.4 [class.mem]. —end note] The size of a union is sufficient to contain the largest of its non-static data members. Each non-static data member is allocated as if it were the sole member of a struct. A union can have...
Date: 2008-09-17.00:00:00

Unions are no longer forbidden to have static data members; however, much of the wording of 11.5 [class.union] (and possibly other places in the Standard) is still written with that assumption and refers only to “data members” when clearly non-static data members are in view. From paragraph 1, for example:

In a union, at most one of the data members can be active at any time... The size of a union is sufficient to contain the largest of its data members...
History
Date User Action Args
2010-03-29 00:00:00adminsetstatus: wp -> cd2
2009-11-08 00:00:00adminsetstatus: dr -> wp
2009-08-03 00:00:00adminsetmessages: + msg2262
2009-08-03 00:00:00adminsetstatus: ready -> dr
2009-03-23 00:00:00adminsetmessages: + msg1892
2009-03-23 00:00:00adminsetstatus: open -> ready
2008-09-17 00:00:00admincreate