[Bug c++/85251] Using declaration for base class constructor looses explicit.

2021-08-04 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85251

--- Comment #3 from Jonathan Wakely  ---
Thanks to ppalka who pointed out that [namespace.udecl] p13 does specify what
should happen here:

  Constructors that are named by a using-declaration are treated as though they
  were constructors of the derived class when looking up the constructors of
the
  derived class ([class.qual]) or forming a set of overload candidates
  ([over.match.ctor], [over.match.copy], [over.match.list]).

So the inherited constructor should still be explicit when considered by
overload resolution.

[Bug c++/85251] Using declaration for base class constructor looses explicit.

2021-08-04 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85251

Jonathan Wakely  changed:

   What|Removed |Added

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

--- Comment #2 from Jonathan Wakely  ---
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.

[Bug c++/85251] Using declaration for base class constructor looses explicit.

2021-08-03 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85251

--- Comment #1 from Andrew Pinski  ---
GCC, ICC, and MSVC all do the same thing and calls A(int).