diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 86b1e37f1081..361bc865d79c 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -5878,12 +5878,20 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, // Convert the arguments. CXXMethodDecl *Method = cast(FnDecl); - if (PerformObjectArgumentInitialization(Args[0], Method) || - PerformCopyInitialization(Args[1], - FnDecl->getParamDecl(0)->getType(), - AA_Passing)) + if (PerformObjectArgumentInitialization(Args[0], Method)) return ExprError(); + // Convert the arguments. + OwningExprResult InputInit + = PerformCopyInitialization(InitializedEntity::InitializeParameter( + FnDecl->getParamDecl(0)), + SourceLocation(), + Owned(Args[1])); + if (InputInit.isInvalid()) + return ExprError(); + + Args[1] = InputInit.takeAs(); + // Determine the result type QualType ResultTy = FnDecl->getType()->getAs()->getResultType();