Created on 2022-11-26.00:00:00 last changed 5 months ago
Proposed resolution (approved by CWG 2024-05-31):
Change in 11.4.5.2 [class.default.ctor] paragraph 3 as follows:
A default constructor for class X is trivial if it is not user-provided and if:Otherwise, the default constructor is non-trivial.
its classX has no virtual functions (11.7.3 [class.virtual]) and no virtual base classes (11.7.2 [class.mi]), and- no non-static data member of
its classX has a default member initializer (11.4 [class.mem]), and- all the direct base classes of its class have trivial default constructors, and
- the constructor selected to default-initialize each direct base class subobject of X is trivial,
- for all the non-static data members of its class that are of class type (or array thereof), each such class has a trivial default constructor.
- for each direct non-static data member of X that is of class type (or array thereof), the constructor selected to default-initialize that member (or an array element of that member) is trivial.
(From submission #521.)
Consider:
template <class T> struct A { A() requires (false) = default; A() : t(42) {} T t; }; struct B : A<int> {};
According to the current wording, class B has a trivial default constructor, which is undesirable.
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-06-28 19:56:12 | admin | set | status: tentatively ready -> review |
2024-05-31 21:07:31 | admin | set | messages: + msg7717 |
2024-05-31 21:07:31 | admin | set | status: review -> tentatively ready |
2024-05-17 22:24:28 | admin | set | status: open -> review |
2022-11-26 00:00:00 | admin | create |