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

2024-10-26


2085. Invalid example of adding special member function via default argument

Section: 6.3  [basic.def.odr]     Status: CD4     Submitter: Hubert Tong     Date: 2015-02-13

[Adopted at the February, 2016 meeting.]

The example in 6.3 [basic.def.odr] bullet 6.6 reads,

  //translation unit 1:
  struct X {
    X(int);
    X(int, int);
  };
  X::X(int = 0) { }
  class D: public X { };
  D d2;     // X(int) called by D()

  //translation unit 2:
  struct X {
    X(int);
    X(int, int);
  };
  X::X(int = 0, int = 0) { }
  class D: public X { };   // X(int, int) called by D();
                           // D()'s implicit definition
                           // violates the ODR

Creating a special member function via default arguments added in an out-of-class definition, as is done here, is no longer permitted, so at a minimum the example should be removed. It is not clear whether there remain any cases to which the normative wording of bullet 6.6 would apply:

If not, the entire bullet should be removed.

Proposed resolution (September, 2015):

Change 6.3 [basic.def.odr] bullet 6.6 as follows: