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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |5.5.0
           Keywords|                            |rejects-valid
   Last reconfirmed|                            |2019-05-24
                 CC|                            |paolo at gcc dot gnu.org
     Ever confirmed|0                           |1
            Summary|Explicit constructor called |[7/8/9/10 Regression]
                   |implicitly                  |Explicit constructor called
                   |                            |implicitly
      Known to fail|                            |10.0, 6.5.0, 7.4.0, 8.3.0,
                   |                            |9.1.0

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Here's a rejects-valid testcase that Clang and EDG accept:

struct M {
  M() = default;
  template <typename T> explicit M(T&&) = delete;
};

struct V {
  V(M m);
};

M m;
V v = m;

GCC tries to use the deleted constructor template instead of the copy
constructor when initializing the parameter of V::V(M):

m.cc:11:7: error: use of deleted function ‘M::M(T&&) [with T = M&]’
 V v = m;
       ^
m.cc:3:34: note: declared here
   template <typename T> explicit M(T&&) = delete;
                                  ^
m.cc:7:3: note:   initializing argument 1 of ‘V::V(M)’
   V(M m);
   ^

M::M<M&>(M&) is a better match for a non-const lvalue than the implicit
M::M(const M&) copy constructor, but because it's explicit it shouldn't be
used.

GCC 5 compiled it OK (with -std=c++11) but it started to be rejected with
r225705:

            PR c++/54521
            * call.c (convert_like_real): Do not set LOOKUP_ONLYCONVERTING for
            the second step of copy-initialization.

Reply via email to