===================================================================
@@ -6437,12 +6437,14 @@ convert_like_real (conversion *convs, tree expr, t
/* Copy-initialization where the cv-unqualified version of the source
type is the same class as, or a derived class of, the class of the
destination [is treated as direct-initialization]. [dcl.init] */
- flags = LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING;
+ flags = LOOKUP_NORMAL;
if (convs->user_conv_p)
/* This conversion is being done in the context of a user-defined
conversion (i.e. the second step of copy-initialization), so
don't allow any more. */
flags |= LOOKUP_NO_CONVERSION;
+ else
+ flags |= LOOKUP_ONLYCONVERTING;
if (convs->rvaluedness_matches_p)
flags |= LOOKUP_PREFER_RVALUE;
if (TREE_CODE (expr) == TARGET_EXPR
===================================================================
@@ -0,0 +1,12 @@
+// PR c++/54521
+
+struct X
+{
+ X(int) {}
+ explicit X(X const &) {}
+};
+
+int main()
+{
+ X x = 1;
+}