From patchwork Thu Oct 27 11:02:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 122105 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 D8D631007D8 for ; Thu, 27 Oct 2011 22:02:43 +1100 (EST) Received: (qmail 20961 invoked by alias); 27 Oct 2011 11:02:38 -0000 Received: (qmail 20938 invoked by uid 22791); 27 Oct 2011 11:02:36 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rcsinet15.oracle.com (HELO rcsinet15.oracle.com) (148.87.113.117) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 27 Oct 2011 11:02:18 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by rcsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id p9RB2HWM001880 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 27 Oct 2011 11:02:17 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id p9RB2GQ7026146 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 27 Oct 2011 11:02:16 GMT Received: from abhmt118.oracle.com (abhmt118.oracle.com [141.146.116.70]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id p9RB2BGb029528; Thu, 27 Oct 2011 06:02:11 -0500 Received: from [192.168.1.4] (/79.52.193.167) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 27 Oct 2011 04:02:10 -0700 Message-ID: <4EA93A2E.9010400@oracle.com> Date: Thu, 27 Oct 2011 13:02:06 +0200 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++ Subject: [v3] Fix libstdc++/50880 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, tested x86_64-linux (with _GLIBCXX_USE_C99_COMPLEX_TR1 manually set to zero for the affected function), committed to mainline. Will go in 4.6.3 too. Thanks, Paolo. /////////////////////// 2011-10-27 Richard B. Kreckel Paolo Carlini PR libstdc++/50880 * include/std/complex (__complex_acosh): Fix for __z.real() < 0. * include/tr1/complex (__complex_acosh): Likewise. * testsuite/26_numerics/complex/50880.cc: New. * testsuite/tr1/8_c_compatibility/complex/50880.cc: Likewise. Index: include/std/complex =================================================================== --- include/std/complex (revision 180561) +++ include/std/complex (working copy) @@ -1690,6 +1690,8 @@ * (__z.real() + __z.imag()) - _Tp(1.0), _Tp(2.0) * __z.real() * __z.imag()); __t = std::sqrt(__t); + if (__z.real() < _Tp(-0.0)) + __t = -__t; return std::log(__t + __z); } Index: include/tr1/complex =================================================================== --- include/tr1/complex (revision 180561) +++ include/tr1/complex (working copy) @@ -189,6 +189,8 @@ * (__z.real() + __z.imag()) - _Tp(1.0), _Tp(2.0) * __z.real() * __z.imag()); __t = std::sqrt(__t); + if (__z.real() < _Tp(-0.0)) + __t = -__t; return std::log(__t + __z); } Index: testsuite/26_numerics/complex/50880.cc =================================================================== --- testsuite/26_numerics/complex/50880.cc (revision 0) +++ testsuite/26_numerics/complex/50880.cc (revision 0) @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++0x" } +// +// 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 +#include + +template + void test01_do() + { + bool test __attribute__((unused)) = true; + + const std::complex ca(T(-2), T(2)); + const std::complex cb(T(-2), T(0)); + const std::complex cc(T(-2), T(-2)); + + std::complex cra = std::acosh(ca); + std::complex crb = std::acosh(cb); + std::complex crc = std::acosh(cc); + + VERIFY( cra.real() > T(0) ); + VERIFY( crb.real() > T(0) ); + VERIFY( crc.real() > T(0) ); + } + +// libstdc++/50880 +void test01() +{ + test01_do(); + test01_do(); + test01_do(); +} + +int main() +{ + test01(); + return 0; +} Index: testsuite/tr1/8_c_compatibility/complex/50880.cc =================================================================== --- testsuite/tr1/8_c_compatibility/complex/50880.cc (revision 0) +++ testsuite/tr1/8_c_compatibility/complex/50880.cc (revision 0) @@ -0,0 +1,51 @@ +// 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 +#include + +template + void test01_do() + { + bool test __attribute__((unused)) = true; + + const std::complex ca(T(-2), T(2)); + const std::complex cb(T(-2), T(0)); + const std::complex cc(T(-2), T(-2)); + + std::complex cra = std::tr1::acosh(ca); + std::complex crb = std::tr1::acosh(cb); + std::complex crc = std::tr1::acosh(cc); + + VERIFY( cra.real() > T(0) ); + VERIFY( crb.real() > T(0) ); + VERIFY( crc.real() > T(0) ); + } + +// libstdc++/50880 +void test01() +{ + test01_do(); + test01_do(); + test01_do(); +} + +int main() +{ + test01(); + return 0; +}