This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


2403. Temporary materialization and base/member initialization

Section: 11.9.3  [class.base.init]     Status: drafting     Submitter: Daveed Vandevoorde     Date: 2018-12-11

Given the following example,

  struct Noncopyable {
    Noncopyable();
    Noncopyable(const Noncopyable &) = delete;
  };

  Noncopyable make(int kind = 0);

  struct AsBase : Noncopyable {
    AsBase() : Noncopyable(make()) {} // #1
  };

  struct AsMember {
    Noncopyable nc;
    AsMember() : nc(make()) { }  // #2?
  };

All implementations treat #1 as an error, invoking the deleted copy constructor, while #2 is accepted. It's not clear from the current wording why they should be treated differently.

Additional note (August, 2022):

If there are concerns about reuse of tail padding in #1, requiring a copy for some implementation reason, similar concerns should apply to #2 if the data member is declared with [[no_unique_address]].

Furthermore, the following example using a delegating constructor shows implementation divergence:

struct Noncopyable {
  Noncopyable();
  Noncopyable(const Noncopyable &) = delete;
  Noncopyable(int) : Noncopyable(Noncopyable()) {} // #3?
};