Date
2016-02-15.00:00:00
Message id
5480

Content

[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 D is a class with an implicitly-declared constructor (11.4.5 [class.ctor]), it is as if the constructor was implicitly defined in every translation unit where it is odr-used, and the implicit definition in every translation unit shall call the same constructor for a base class or a class member of D.

If not, the entire bullet should be removed.