Title
Indirect private base classes in aggregates
Status
c++23
Section
9.4.2 [dcl.init.aggr]
Submitter
Chris Bowler

Created on 2022-07-21.00:00:00 last changed 17 months ago

Messages

Date: 2022-08-26.21:45:07

Proposed resolution (approved by CWG 2022-08-26):

Change in 9.4.2 [dcl.init.aggr] paragraph 1 as follows:

An aggregate is an array or a class (Clause 11 [class]) with
  • no user-declared or inherited constructors (11.4.5 [class.ctor]),
  • no private or protected direct non-static data members (11.8 [class.access]),
  • no private or protected direct base classes (11.8.3 [class.access.base]), and
  • no virtual functions (11.7.3 [class.virtual]) or virtual base classes (11.7.2 [class.mi])., and
  • no virtual, private, or protected base classes (11.7.2 [class.mi]).
Date: 2022-11-15.00:00:00

[Accepted as a DR at the November, 2022 meeting.]

The wording appears to prohibit aggregates from having indirect private base classes. That does not match existing practice and is an unnecessary restriction. For example:

#include <type_traits>

struct B1 {};
struct B2 : private B1 {};
struct S : public B2 {};

void f() {
  static_assert(std::is_aggregate<S>::value);
}
History
Date User Action Args
2023-07-16 13:00:43adminsetstatus: open -> c++23
2023-07-16 13:00:43adminsetstatus: drwp -> open
2023-02-18 18:43:04adminsetstatus: dr -> drwp
2022-11-25 05:14:04adminsetstatus: ready -> dr
2022-08-26 21:45:07adminsetstatus: open -> ready
2022-08-21 08:22:34adminsetmessages: + msg6894
2022-07-21 00:00:00admincreate