Issue2277

Title 2277. Ambiguity inheriting constructors with default arguments
Status drwp Section 16.3.3.2 [over.ics.rank]
Submitter Richard Smith

Created on 2016-06-23.00:00:00 by admin, last changed by admin.

Messages
msg6110 (view) Date: 2017-07-15.00:00:00

[Voted into the WP at the July, 2017 meeting.]

msg6109 (view) Date: 2017-05-15.00:00:00

Proposed resolution (May, 2017):

This issue is resolved by the resolution of issue 2273.

msg5914 (view) Date: 2018-02-27.00:00:00

In an example like:

  struct A { 
    A(int, int = 0); 
    void f(int, int = 0); 
  }; 
  struct B : A { 
    B(int); using A::A; 
    void f(int); using A::f; 
  } 

calls to B(int) and B::f(int) are ambiguous, because they could equally call the version inherited from the base class. This doesn't match the intent in 10.3.3 [namespace.udecl], which usually makes derived-class functions take precedence over ones from a base class.

The above patterns are not common, although they sometimes cause breakage when refactoring a base class. However, P0136R1 brings this into sharp focus, because it causes the rejection of the following formerly-valid and very reasonable code:

  struct A { 
    A(int = 0); 
  }; 
  struct B : A { 
    using B::B; 
  }; 
  B b; 
History
Date User Action Args
2018-02-27 00:00:00adminsetstatus: open -> drwp
section: 13.3.3.2 [over.ics.rank] -> 16.3.3.2 [over.ics.rank]
2018-02-27 00:00:00adminsetmessages: + msg6110
2018-02-27 00:00:00adminsetmessages: + msg6109
2016-06-23 00:00:00admincreate