From patchwork Tue Jun 26 12:16:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 167394 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 DC149B6F5A for ; Tue, 26 Jun 2012 22:16:48 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1341317809; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Cc:Subject:Message-ID:User-Agent:MIME-Version: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=pR0CikG ZMEAs7HMt3pqoNZjbdT0=; b=suDKLVmK403bRILXzJ74gaPwGX18DvpHfGjIzRv 32hy8r63P9dZHkzqnKFZ8gtA4WKhNB6YX9nK/kp6Q8fcJ7TXkH80XQSOnNC5YDxa VM16VGNmqS3uBA0COr3vxilY0tazxAnMk4v75ic/ga4SmjR172GXZ9cGEn0LmXdh vUNk= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Date:From:To:Cc:Subject:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=yIJiu8p+1uv+km8uLRXKHaZFEWbY7CFwwxdpINtPq9a6G3UhwH73VI9Kqt3vMR O+3rvMZqrq3LZ7XaYmWqitL4T4VhAEBr9eMJxW80aFUwvmyIv0s7yQm+G1Py1zx8 7j7DcIMwE6aHwoZOa4k5sVvTumk3P5HmZnFYqKowa0ySc=; Received: (qmail 3431 invoked by alias); 26 Jun 2012 12:16:40 -0000 Received: (qmail 3418 invoked by uid 22791); 26 Jun 2012 12:16:35 -0000 X-SWARE-Spam-Status: No, hits=-5.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 26 Jun 2012 12:16:20 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id A677CA6720; Tue, 26 Jun 2012 14:16:18 +0200 (CEST) Date: Tue, 26 Jun 2012 14:16:18 +0200 (CEST) From: Richard Guenther To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com Subject: [PATCH][C++] Fix PR53752 Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 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 This fixes PR53752 - reinstantiating the behavior for an array with domain [0, USIZE_MAX] during mangling (mangle it as zero-size array). Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk and the 4.7 branch? Thanks, Richard. 2012-06-26 Richard Guenther PR c++/53752 * mangle.c (write_array_type): Truncate the number-of-elements result. * g++.dg/torture/pr53752.C: New testcase. Index: gcc/cp/mangle.c =================================================================== --- gcc/cp/mangle.c (revision 188927) +++ gcc/cp/mangle.c (working copy) @@ -3121,6 +3121,9 @@ write_array_type (const tree type) elements in the array, not the largest allowed index. */ double_int dmax = double_int_add (tree_to_double_int (max), double_int_one); + /* Truncate the result - this will mangle [0, SIZE_INT_MAX] + number of elements as zero. */ + dmax = double_int_zext (dmax, TYPE_PRECISION (TREE_TYPE (max))); gcc_assert (double_int_fits_in_uhwi_p (dmax)); write_unsigned_number (dmax.low); } Index: gcc/testsuite/g++.dg/torture/pr53752.C =================================================================== --- gcc/testsuite/g++.dg/torture/pr53752.C (revision 0) +++ gcc/testsuite/g++.dg/torture/pr53752.C (revision 0) @@ -0,0 +1,156 @@ +// { dg-do compile } +// { dg-options "-g" } + +typedef unsigned int uint32_t; +typedef unsigned long int uint64_t; +namespace mpl_ { + template< typename T, T N > struct integral_c { + static const T value = N; + }; +} +namespace mpl { + using namespace mpl_; +}; +template struct integral_constant : public mpl::integral_c { + typedef integral_constant type; +}; +template< typename T > struct is_lvalue_reference : public ::integral_constant { +}; +template< typename T > struct is_rvalue_reference : public ::integral_constant { +}; +namespace type_traits { + template struct ice_or; + template <> struct ice_or { + static const bool value = false; + }; +} +template struct is_reference_impl { + static const bool value = (::type_traits::ice_or< ::is_lvalue_reference::value, ::is_rvalue_reference::value >::value) ; +}; +template< typename T > struct is_reference : public ::integral_constant::value> { +}; +struct na { +}; +namespace mpl { + template< bool C , typename T1 , typename T2 > struct if_c { + typedef T2 type; + }; + template< typename T1 = na , typename T2 = na , typename T3 = na > struct if_ { + typedef if_c< static_cast(T1::value) , T2 , T3 > almost_type_; + typedef typename almost_type_::type type; + }; +} +namespace optional_detail { + template struct types_when_isnt_ref { + typedef T & reference_type ; + } + ; + template struct types_when_is_ref { + } + ; + struct optional_tag { + } + ; + template class optional_base : public optional_tag { + typedef types_when_isnt_ref types_when_not_ref ; + typedef types_when_is_ref types_when_ref ; + protected : + typedef typename is_reference::type is_reference_predicate ; + typedef typename mpl::if_::type types ; + typedef typename types::reference_type reference_type ; + } + ; +} +template class optional : public optional_detail::optional_base { + typedef optional_detail::optional_base base ; +public : + typedef typename base::reference_type reference_type ; + reference_type operator *() { + } +}; +namespace noncopyable_ { + class noncopyable { + }; +} +typedef noncopyable_::noncopyable noncopyable; +template class shared_ptr { +public: + T * operator-> () const { + } +}; +typedef uint64_t block_address; +class transaction_manager : noncopyable { +public: + typedef shared_ptr ptr; +}; +template class NoOpRefCounter { +}; +struct uint64_traits { +}; +namespace btree_detail { + class shadow_spine : private noncopyable { + public: + shadow_spine(transaction_manager::ptr tm) : tm_(tm) { + } + transaction_manager::ptr tm_; + }; +} +template class btree { +public: + typedef shared_ptr > ptr; + typedef uint64_t key[Levels]; + typedef typename ValueTraits::value_type value_type; + typedef optional maybe_value; + btree(typename transaction_manager::ptr tm, typename ValueTraits::ref_counter rc); + maybe_value lookup(key const &key) const; + void insert(key const &key, typename ValueTraits::value_type const &value); + template bool insert_location(btree_detail::shadow_spine &spine, block_address block, uint64_t key, int *index); + typename transaction_manager::ptr tm_; + block_address root_; + typename ValueTraits::ref_counter rc_; +}; +template void btree:: insert(key const &key, typename ValueTraits::value_type const &value) { + using namespace btree_detail; + block_address block = root_; + int index = 0; + shadow_spine spine(tm_); + for (unsigned level = 0; + level < Levels - 1; + ++level) { + bool need_insert = insert_location(spine, block, key[level], &index); + if (need_insert) { + btree new_tree(tm_, rc_); + } + } +} +struct device_details_disk { +} +__attribute__ ((packed)); +struct device_details { +}; +struct device_details_traits { + typedef device_details value_type; + typedef NoOpRefCounter ref_counter; +}; +typedef uint32_t thin_dev_t; +typedef btree<1, device_details_traits> detail_tree; +struct metadata { + typedef shared_ptr ptr; + detail_tree::ptr details_; +}; +class thin_pool; +class thin { + void set_snapshot_time(uint32_t time); + thin_dev_t dev_; + thin_pool *pool_; +}; +class thin_pool { +public: + metadata::ptr md_; +}; +void thin::set_snapshot_time(uint32_t time) { + uint64_t key[1] = { + dev_ }; + optional mdetail = pool_->md_->details_->lookup(key); + pool_->md_->details_->insert(key, *mdetail); +}