Title
Reference to anonymous union?
Status
cd3
Section
11.5 [class.union]
Submitter
Daveed Vandevoorde

Created on 2011-08-16.00:00:00 last changed 131 months ago

Messages

Date: 2012-10-15.00:00:00

[Moved to DR at the October, 2012 meeting.]

Date: 2012-02-15.00:00:00

Proposed resolution (February, 2012):

Change 11.5 [class.union] paragraph 7:

A union for which objects, or pointers, or references are declared is not an anonymous union. [Example:

  void f() {
    union { int aa; char* p; } obj, *ptr = &obj;
    aa = 1;      // error
    ptr->aa = 1; // OK
  }
Date: 2011-08-16.00:00:00

According to 11.5 [class.union] paragraph 7,

A union for which objects or pointers are declared is not an anonymous union.

This should also apply to references, which are now possible because decltype allows writing an initializer for an unnamed union:

    char buf[100];
    union {
      int i;
    } &r = (decltype(r)) buf;
History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-05-03 00:00:00adminsetstatus: dr -> drwp
2012-11-03 00:00:00adminsetmessages: + msg4152
2012-11-03 00:00:00adminsetstatus: ready -> dr
2012-02-27 00:00:00adminsetmessages: + msg3728
2012-02-27 00:00:00adminsetstatus: open -> ready
2011-08-16 00:00:00admincreate