From patchwork Mon Nov 21 11:23:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 126745 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]) by ozlabs.org (Postfix) with SMTP id 43498B708F for ; Mon, 21 Nov 2011 22:24:18 +1100 (EST) Received: (qmail 5923 invoked by alias); 21 Nov 2011 11:24:15 -0000 Received: (qmail 5903 invoked by uid 22791); 21 Nov 2011 11:24:10 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from acsinet15.oracle.com (HELO acsinet15.oracle.com) (141.146.126.227) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 21 Nov 2011 11:23:55 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by acsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id pALBNsGF019846 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 21 Nov 2011 11:23:54 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id pALBNrxL024907 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 21 Nov 2011 11:23:53 GMT Received: from abhmt113.oracle.com (abhmt113.oracle.com [141.146.116.65]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id pALBNmJr010163; Mon, 21 Nov 2011 05:23:48 -0600 Received: from [192.168.1.4] (/79.53.13.169) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 21 Nov 2011 03:23:47 -0800 Message-ID: <4ECA349C.3070400@oracle.com> Date: Mon, 21 Nov 2011 12:23:08 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: libstdc++ , =?ISO-8859-1?Q?Daniel_Kr=FCgler?= Subject: [v3] libstdc++/51185 X-IsSubscribed: yes 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 Hi, I'm committing the below from Daniel. Thanks! Tested x86_64-linux. Paolo. /////////////////// 2011-11-21 Daniel Krugler PR libstdc++/51185 * include/std/type_traits (__is_base_to_derived_ref, __is_lvalue_to_rvalue_ref): Fix. * testsuite/20_util/is_constructible/51185.cc: New. * testsuite/20_util/is_constructible/value-2.cc: Extend. * testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error line number. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc Likewise. Index: include/std/type_traits =================================================================== --- include/std/type_traits (revision 181554) +++ include/std/type_traits (working copy) @@ -745,6 +745,8 @@ // Implementation for non-reference types. To meet the proper // variable definition semantics, we also need to test for // is_destructible in this case. + // This form should be simplified by a single expression: + // ::delete ::new _Tp(declval<_Arg>()), see c++/51222. struct __do_is_direct_constructible_impl { template::value> + = __not_<__or_, + is_function<_From>>>::value> struct __is_base_to_derived_ref; + // Detect whether we have a downcast situation during + // reference binding. template struct __is_base_to_derived_ref<_From, _To, true> { @@ -803,6 +808,8 @@ is_rvalue_reference<_To>>::value> struct __is_lvalue_to_rvalue_ref; + // Detect whether we have an lvalue of non-function type + // bound to a reference-compatible rvalue-reference. template struct __is_lvalue_to_rvalue_ref<_From, _To, true> { @@ -810,8 +817,9 @@ _From>::type>::type __src_t; typedef typename remove_cv::type>::type __dst_t; - typedef __or_, - is_base_of<__dst_t, __src_t>> type; + typedef __and_<__not_>, + __or_, + is_base_of<__dst_t, __src_t>>> type; static constexpr bool value = type::value; }; @@ -823,9 +831,9 @@ // Here we handle direct-initialization to a reference type as // equivalent to a static_cast modulo overshooting conversions. // These are restricted to the following conversions: - // a) A glvalue of a base class to a derived class reference + // a) A base class value to a derived class reference // b) An lvalue to an rvalue-reference of reference-compatible - // types + // types that are not functions template struct __is_direct_constructible_ref_cast : public __and_<__is_static_castable<_Arg, _Tp>, @@ -850,7 +858,9 @@ // Since default-construction and binary direct-initialization have // been handled separately, the implementation of the remaining - // n-ary construction cases is rather straightforward. + // n-ary construction cases is rather straightforward. We can use + // here a functional cast, because array types are excluded anyway + // and this form is never interpreted as a C cast. struct __do_is_nary_constructible_impl { template. -// { dg-error "static assertion failed" "" { target *-*-* } 1759 } +// { dg-error "static assertion failed" "" { target *-*-* } 1769 } #include Index: testsuite/20_util/is_constructible/value-2.cc =================================================================== --- testsuite/20_util/is_constructible/value-2.cc (revision 181554) +++ testsuite/20_util/is_constructible/value-2.cc (working copy) @@ -817,3 +817,5 @@ "Error"); static_assert(!std::is_constructible>::value, "Error"); + +static_assert(std::is_constructible::value, "Error"); Index: testsuite/20_util/is_constructible/51185.cc =================================================================== --- testsuite/20_util/is_constructible/51185.cc (revision 0) +++ testsuite/20_util/is_constructible/51185.cc (revision 0) @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +struct A { }; +struct B : A { }; + +// libstdc++/51185 +void f() +{ + static_assert(!std::is_constructible(), ""); + static_assert(!std::is_constructible(), ""); + static_assert(!std::is_constructible(), ""); + static_assert(!std::is_constructible(), ""); + static_assert(!std::is_constructible(), ""); + static_assert(!std::is_constructible(), ""); + static_assert(!std::is_constructible(), ""); + static_assert(!std::is_constructible(), ""); + static_assert(!std::is_constructible(), ""); +}