Class completeness in non-static data member initializers
11.4 [class.mem]
Jason Merrill

Created on 2011-09-23.00:00:00 last changed 49 months ago


Date: 2014-11-15.00:00:00

[Moved to DR at the November, 2014 meeting.]

Date: 2014-02-15.00:00:00

Proposed resolution (February, 2014):

Change 11.4 [class.mem] paragraph 4 as follows:

A brace-or-equal-initializer shall appear only in the declaration of a data member. (For static data members, see [class.static.data]; for non-static data members, see 11.9.3 [class.base.init]). A brace-or-equal-initializer for a non-static data member shall not directly or indirectly cause the implicit definition of a defaulted default constructor for the enclosing class or the exception-specification of that constructor.
Date: 2013-09-15.00:00:00

Notes from the September, 2013 meeting:

One approach that might be considered would be to parse deferred portions lazily, on demand, and then issue an error if this results in a cycle.

Date: 2013-03-15.00:00:00

Additional note (March, 2013):

A specific example:

  struct A {
    void *p = A{};
    operator void*() const { return nullptr; }

Perhaps the best way of addressing this would be to make it ill-formed for a non-static data member initializer to use a defaulted constructor of its class.

See also issue 1360.

Date: 2011-09-23.00:00:00

In Bloomington there was general agreement that given a class that uses non-static data member initializers, the exception-specification for the default constructor depends on whether those initializers are noexcept. However, according to 11.4 [class.mem] paragraph 2, the class is regarded as complete within the brace-or-equal-initializers for non-static data members.

This suggests that we need to finish processing the class before parsing the NSDMI, but our direction on issue 1351 suggests that we need to parse the NSDMI in order to finish processing the class. Can't have both...

Date User Action Args
2017-02-06 00:00:00adminsetstatus: drwp -> cd4
2015-05-25 00:00:00adminsetstatus: dr -> drwp
2015-04-13 00:00:00adminsetmessages: + msg5390
2014-11-24 00:00:00adminsetstatus: ready -> dr
2014-05-27 00:00:00adminsetstatus: drafting -> ready
2014-03-03 00:00:00adminsetmessages: + msg4888
2013-10-14 00:00:00adminsetmessages: + msg4627
2013-10-14 00:00:00adminsetstatus: open -> drafting
2013-03-18 00:00:00adminsetmessages: + msg4286
2011-09-23 00:00:00admincreate