From patchwork Tue Jun 3 15:24:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 355573 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 DFD0B14007C for ; Wed, 4 Jun 2014 01:27:35 +1000 (EST) 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:subject:references :in-reply-to:content-type; q=dns; s=default; b=rmBKOlpgDLQIzEwUM Uyuiv/vNZHx4RCxtpKu8+GDq4mf979BtB8AKYD9zTavLkekYbXMXDA2GFIFMtq/8 QbtvV2Fub0UErSyKFhtY0br1Uuj3wHcSl/NJvIwgc1jXZC8ktnb5nqikKq6hIuSa VwhDob3km95hflz5sBRNO55ZQc= 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:subject:references :in-reply-to:content-type; s=default; bh=UoxOuIKkY7l8/CTkLpVQC8V z5rM=; b=Z3MHo/HJ74HyZhw5Xqm24p9Izbonr4NTHWVWWOSAXqtisC2MsnSrNld eE2dnZGEYvwfGeV4RiKcJZZE6KdpL5xprU+M75ATBP2SRMHZ2/9rIe4slmc5k9N2 4Yu2BsMnh/Msnb3k3c86sosM8lesSM8iedxUlO5NUStA6zKcY2EQ= Received: (qmail 24482 invoked by alias); 3 Jun 2014 15:27:28 -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 24466 invoked by uid 89); 3 Jun 2014 15:27:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham 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-SHA encrypted) ESMTPS; Tue, 03 Jun 2014 15:27:26 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s53FRNae027749 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 3 Jun 2014 15:27:24 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s53FRMo7022485 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 3 Jun 2014 15:27:23 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s53FRMk4024301; Tue, 3 Jun 2014 15:27:22 GMT Received: from [192.168.1.4] (/79.33.215.66) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Jun 2014 08:27:22 -0700 Message-ID: <538DE8B0.6060404@oracle.com> Date: Tue, 03 Jun 2014 17:24:32 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Jason Merrill , "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] PR 52174 aka DR 1423 References: <538DDBF6.70102@oracle.com> <538DE397.80707@redhat.com> In-Reply-To: <538DE397.80707@redhat.com> X-IsSubscribed: yes Hi, On 06/03/2014 05:02 PM, Jason Merrill wrote: > Right. In the case of > >> + TDerived() >> + : TBase(nullptr) { } > > we have direct-initialization of TBase, but the parameter of the > TBase constructor is copy-initialized, so nullptr32.C is ill-formed; > please drop this hunk of the patch. Oops, now I see, thanks. Thus I'm finishing testing the below. Thanks, Paolo. //////////////////// gcc/cp 2014-06-03 Paolo Carlini DR 1423 PR c++/52174 * call.c (standard_conversion): Convert nullptr to bool only in case of direct-initialization. gcc/testsuite 2014-06-03 Paolo Carlini DR 1423 PR c++/52174 * g++.dg/cpp0x/nullptr31.C: New. * g++.dg/cpp0x/sfinae-nullptr1.C: Likewise. * g++.dg/cpp0x/nullptr17.C: Update. libstdc++-v3 2014-06-03 Paolo Carlini DR 1423 PR c++/52174 * testsuite/20_util/is_assignable/value.cc: Update. Index: gcc/cp/call.c =================================================================== --- gcc/cp/call.c (revision 211162) +++ gcc/cp/call.c (working copy) @@ -1311,10 +1311,10 @@ standard_conversion (tree to, tree from, tree expr { /* [conv.bool] - An rvalue of arithmetic, unscoped enumeration, pointer, or - pointer to member type can be converted to an rvalue of type - bool. ... An rvalue of type std::nullptr_t can be converted - to an rvalue of type bool; */ + A prvalue of arithmetic, unscoped enumeration, pointer, or pointer + to member type can be converted to a prvalue of type bool. ... + For direct-initialization (8.5 [dcl.init]), a prvalue of type + std::nullptr_t can be converted to a prvalue of type bool; */ if (ARITHMETIC_TYPE_P (from) || UNSCOPED_ENUM_P (from) || fcode == POINTER_TYPE @@ -1328,6 +1328,8 @@ standard_conversion (tree to, tree from, tree expr && conv->rank < cr_pbool) || NULLPTR_TYPE_P (from)) conv->rank = cr_pbool; + if (NULLPTR_TYPE_P (from) && (flags & LOOKUP_ONLYCONVERTING)) + conv->bad_p = true; return conv; } Index: gcc/testsuite/g++.dg/cpp0x/nullptr17.C =================================================================== --- gcc/testsuite/g++.dg/cpp0x/nullptr17.C (revision 211162) +++ gcc/testsuite/g++.dg/cpp0x/nullptr17.C (working copy) @@ -1,6 +1,7 @@ // { dg-do compile { target c++11 } } -// Test that bool is a better overload match than int +// Used to test that bool is a better overload match than int +// Updated for DR 1423 template struct tType_equal; template struct tType_equal { typedef void type; }; @@ -16,7 +17,7 @@ bool i( bool ); void test_i() { // Overload to bool, not int - type_equal(i(nullptr)); + type_equal(i(nullptr)); // { dg-error "invalid conversion" } decltype(nullptr) mynull = 0; - type_equal(i(mynull)); + type_equal(i(mynull)); // { dg-error "invalid conversion" } } Index: gcc/testsuite/g++.dg/cpp0x/nullptr31.C =================================================================== --- gcc/testsuite/g++.dg/cpp0x/nullptr31.C (revision 0) +++ gcc/testsuite/g++.dg/cpp0x/nullptr31.C (working copy) @@ -0,0 +1,11 @@ +// DR 1423, PR c++/52174 +// { dg-do compile { target c++11 } } + +bool b1 = nullptr; // { dg-error "invalid conversion" } + +bool b2(nullptr); +bool b3{nullptr}; + +int i1 = nullptr; // { dg-error "cannot convert" } +int i2(nullptr); // { dg-error "cannot convert" } +int i3{nullptr}; // { dg-error "cannot convert" } Index: gcc/testsuite/g++.dg/cpp0x/sfinae-nullptr1.C =================================================================== --- gcc/testsuite/g++.dg/cpp0x/sfinae-nullptr1.C (revision 0) +++ gcc/testsuite/g++.dg/cpp0x/sfinae-nullptr1.C (working copy) @@ -0,0 +1,18 @@ +// DR 1423, PR c++/52174 +// { dg-do compile { target c++11 } } + +template +T&& make(); + +template +void sink(T); + +template(make())) +> +auto f(int) -> char(&)[1]; + +template +auto f(...) -> char(&)[2]; + +static_assert(sizeof(f(0)) != 1, ""); Index: libstdc++-v3/testsuite/20_util/is_assignable/value.cc =================================================================== --- libstdc++-v3/testsuite/20_util/is_assignable/value.cc (revision 211151) +++ libstdc++-v3/testsuite/20_util/is_assignable/value.cc (working copy) @@ -174,7 +174,7 @@ static_assert(!std::is_assignable::valu static_assert(std::is_assignable::value, "Error"); static_assert(std::is_assignable::value, "Error"); static_assert(std::is_assignable::value, "Error"); -static_assert(std::is_assignable::value, "Error"); +static_assert(!std::is_assignable::value, "Error"); static_assert(std::is_assignable::value, "Error");