https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85251

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-08-04
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Clang's behaviour seems less surprising, but I think it's wrong. See
[class.inhctor.init] which says that initialization of a B via an inherited
constructor "proceeds as if a defaulted default constructor were used to
initialize the B object and each base class subobject from which the
constructor was inherited, except that the A subobject is initialized by the
invocation of the inherited constructor."

So the initialization of 'b' from 'ac' is as if it used a constructor like:

  B() : A(ac) { }

This uses direct-initialization for the A base-class, so the explicit
constructor is usable, and gets preferred by overload resolution.

https://wg21.link/cwg992 seems somewhat related. "The CWG did not see a
correlation between the explicitness of a base class constructor and that of an
implicitly-declared derived class constructor." That's not exactly the same
case though, as the inherited constructors are not implicitly-declared (they
are declared by the using-declaration 'using A::A').

I think this should be clarified by CWG, because it seems reasonable to expect
explicit-ness to be inherited.

Reply via email to