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
[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.
Proposed resolution (September, 2015):
Change 6.3 [basic.def.odr] bullet 6.6 as follows:
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 subobject
of D. [Example:
//translation unit 1: struct X { X(int, int); X(int, int, int); }; X::X(int, int = 0) { } class D: public X{ X x = 0; }; D d2; // X(int, int) called by D() //translation unit 2: struct X { X(int, int); X(int, int, int); }; X::X(int, int = 0, int = 0) { } class D: public X{ X x = 0; }; // X(int, int, int) called by D(); // D()'s implicit definition // violates the ODR
—end example]