From patchwork Wed Oct 23 11:49:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 285649 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2C5B92C00C2 for ; Wed, 23 Oct 2013 22:50:00 +1100 (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:cc:subject:content-type; q=dns; s=default; b=t/GgoUp+fG6Nz/wGQ7pAYKaWgUxWmhOqGwxJy0wAG0w fer3EflvYRp6Um2W3uYdhHCYuBvz6OnAeG1pnw/9wAN2/x+S7eb/cg6WRjS0XNSB 6+4wj0WR50XqM5rCd8COYKZhmjikpXT3qqwjvFtUmimdPWFcW5cCKenniFKS9Gcw = 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=WZdJklpCQa1ZVr0+5SLxrfMpyGE=; b=V1jy9NjhtWS/XCJWt OzV8TgbuwdTKIroGsO54INB8skY4gPGYxt6th88Sea/KDI6/M8tYMfffuIdgU3I/ EwGy6YGIxEatOlZGv811cdpb2cXqD31UiNe4Eer6rlceCq0boWFDf9dX4z4qbHL7 pWmzY4MEWo7HeWlBFIUtyS1Uwc= Received: (qmail 3588 invoked by alias); 23 Oct 2013 11:49:45 -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 3570 invoked by uid 89); 23 Oct 2013 11:49:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients 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; Wed, 23 Oct 2013 11:49:43 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r9NBneKc005741 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 23 Oct 2013 11:49:41 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r9NBndRN018023 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 23 Oct 2013 11:49:40 GMT Received: from abhmt108.oracle.com (abhmt108.oracle.com [141.146.116.60]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r9NBndSb014182; Wed, 23 Oct 2013 11:49:39 GMT Received: from poldo4.casa (/79.52.234.117) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 23 Oct 2013 04:49:39 -0700 Message-ID: <5267B7D1.8060209@oracle.com> Date: Wed, 23 Oct 2013 13:49:37 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: libstdc++ Subject: [v3] Fix libstdc++/58815 X-IsSubscribed: yes Hi, for details see the audit trail. Tested x86_64-linux, committed to mainline. Thanks, Paolo. ////////////////////// 2013-10-23 Paolo Carlini PR libstdc++/58815 * include/decimal/decimal (decimal32::operator long long(), decimal64::operator long long(), decimal128::operator long long()): Add in c++11 mode per n3407. * testsuite/decimal/pr58815.cc: New. Index: include/decimal/decimal =================================================================== --- include/decimal/decimal (revision 203951) +++ include/decimal/decimal (working copy) @@ -250,8 +250,11 @@ /// Conforming extension: Conversion from scalar decimal type. decimal32(__decfloat32 __z) : __val(__z) {} - // 3.2.2.5 Conversion to integral type. (DISABLED) - //operator long long() const { return (long long)__val; } +#if __cplusplus >= 201103L + // 3.2.2.5 Conversion to integral type. + // Note: explicit per n3407. + explicit operator long long() const { return (long long)__val; } +#endif // 3.2.2.6 Increment and decrement operators. decimal32& operator++() @@ -333,8 +336,11 @@ /// Conforming extension: Conversion from scalar decimal type. decimal64(__decfloat64 __z) : __val(__z) {} - // 3.2.3.5 Conversion to integral type. (DISABLED) - //operator long long() const { return (long long)__val; } +#if __cplusplus >= 201103L + // 3.2.3.5 Conversion to integral type. + // Note: explicit per n3407. + explicit operator long long() const { return (long long)__val; } +#endif // 3.2.3.6 Increment and decrement operators. decimal64& operator++() @@ -417,8 +423,11 @@ /// Conforming extension: Conversion from scalar decimal type. decimal128(__decfloat128 __z) : __val(__z) {} - // 3.2.4.5 Conversion to integral type. (DISABLED) - //operator long long() const { return (long long)__val; } +#if __cplusplus >= 201103L + // 3.2.4.5 Conversion to integral type. + // Note: explicit per n3407. + explicit operator long long() const { return (long long)__val; } +#endif // 3.2.4.6 Increment and decrement operators. decimal128& operator++() Index: testsuite/decimal/pr58815.cc =================================================================== --- testsuite/decimal/pr58815.cc (revision 0) +++ testsuite/decimal/pr58815.cc (working copy) @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++11" } +// +// Copyright (C) 2013 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 +// . + +// { dg-do compile } +// { dg-require-effective-target dfp } + +#include + +void +test01 () +{ + std::decimal::decimal32 d32; + std::decimal::decimal64 d64; + std::decimal::decimal128 d128; + + static_cast(d32); + static_cast(d64); + static_cast(d128); +}