From patchwork Fri Jul 10 16:56:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 493840 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E07D41402B0 for ; Sat, 11 Jul 2015 02:57:39 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=bUzKyy4Q; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=QyUmNYnQRIEy/7OS9+SVzLz61ZFswjSyLxib0VwJOM0 6yUDm5FrdEcwYD4TP7seiqbXJcUrTErau6dZMW1qSNeOaL+Am/asbT0dJPRH5pDi jj+Zo/6J9ewGp/uQFWGKNIkLNpOQmMCUXKgf7eZQevTxPEyfcpMYuBEy3hhFSKK8 = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=CNe+mC3yJIDXh6kWQCxbIeiKaMA=; b=bUzKyy4QkNO/ydDUM PUVrRrMmYE8+RYtX71kEgDnwLXL5V6SkKtx2hKriQ714cb0TmyQvwXqnBXMpIa+V 9oeTU7OmdQr814ylMJY0DzAHJCiL2AXuuAXM89PKcD0cFUZxOLQH1g8BOy8uD7D0 FG/+ibgeC28LU43QFXft56qE+A= Received: (qmail 28128 invoked by alias); 10 Jul 2015 16:57:32 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 28119 invoked by uid 89); 10 Jul 2015 16:57:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 10 Jul 2015 16:57:31 +0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t6AGvT4J004827 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 10 Jul 2015 16:57:29 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id t6AGvSut017538 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 10 Jul 2015 16:57:28 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t6AGu48i011281; Fri, 10 Jul 2015 16:57:28 GMT Received: from [192.168.1.4] (/82.49.49.25) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 10 Jul 2015 09:56:04 -0700 Message-ID: <559FF922.4040705@oracle.com> Date: Fri, 10 Jul 2015 18:56:02 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch/RFC] PR 54521 X-IsSubscribed: yes Hi, in this rather old issue, we fail to include explicit constructors in the second step of a copy-initialization and the below is rejected. I'm not 100% sure, but using the existing comments as a guide, I think I found the place where we wrongly set LOOKUP_ONLYCONVERTING for the second step too. The minimal change passes testing, anyway. Thanks, Paolo. //////////////////////// Index: cp/call.c =================================================================== --- cp/call.c (revision 225678) +++ cp/call.c (working copy) @@ -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 Index: testsuite/g++.dg/init/explicit3.C =================================================================== --- testsuite/g++.dg/init/explicit3.C (revision 0) +++ testsuite/g++.dg/init/explicit3.C (working copy) @@ -0,0 +1,12 @@ +// PR c++/54521 + +struct X +{ + X(int) {} + explicit X(X const &) {} +}; + +int main() +{ + X x = 1; +}