From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16509 invoked by alias); 28 Apr 2011 10:51:55 -0000 Received: (qmail 16489 invoked by uid 22791); 28 Apr 2011 10:51:53 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from smtp205.alice.it (HELO smtp205.alice.it) (82.57.200.101) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 28 Apr 2011 10:51:37 +0000 Received: from [192.168.1.4] (79.52.194.192) by smtp205.alice.it (8.5.124.08) id 4DB13A49007770E8; Thu, 28 Apr 2011 12:51:35 +0200 Message-ID: <4DB946A0.2080803@oracle.com> Date: Thu, 28 Apr 2011 12:03:00 -0000 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110221 SUSE/3.1.8 Thunderbird/3.1.8 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: libstdc++ Subject: [v3] Fix libstdc++/48760 (library proper part) Content-Type: multipart/mixed; boundary="------------070906050301080203080605" X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-04/txt/msg02209.txt.bz2 This is a multi-part message in MIME format. --------------070906050301080203080605 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 326 Hi, now that Jason implemented list-initialization of complex in mainline, we can fix this completely in the library. For 4_6-branch I mean to fix it only in C++03 mode, where we can do work in the body (the constructor is constexpr in C++0x mode). Tested x86_64-linux, applied to mainline. Paolo. //////////////////// --------------070906050301080203080605 Content-Type: text/plain; name="CL_48760" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="CL_48760" Content-length: 596 2011-04-28 Paolo Carlini PR libstdc++/48760 * include/std/complex (complex::complex(float, float), complex::complex(double, double), complex::complex(long double, long double)): Use list-initialization in C++0x mode, initialize in the body in C++03 mode. * testsuite/26_numerics/complex/cons/48760.cc: New. * testsuite/26_numerics/complex/cons/48760_c++0x.cc: Likewise. 2011-04-28 Paolo Carlini * include/std/bitset (_Base_bitset(unsigned long long)): Minor tweak, remove redundant round braces. --------------070906050301080203080605 Content-Type: text/plain; name="patch_48760" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch_48760" Content-length: 6248 Index: include/std/bitset =================================================================== --- include/std/bitset (revision 173064) +++ include/std/bitset (working copy) @@ -80,11 +80,11 @@ #ifdef __GXX_EXPERIMENTAL_CXX0X__ constexpr _Base_bitset(unsigned long long __val) - : _M_w({ _WordT(__val) + : _M_w{ _WordT(__val) #if __SIZEOF_LONG_LONG__ > __SIZEOF_LONG__ , _WordT(__val >> _GLIBCXX_BITSET_BITS_PER_WORD) #endif - }) { } + } { } #else _Base_bitset(unsigned long __val) : _M_w() Index: include/std/complex =================================================================== --- include/std/complex (revision 173064) +++ include/std/complex (working copy) @@ -1,7 +1,7 @@ // The template and inlines for the -*- C++ -*- complex number classes. // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, -// 2006, 2007, 2008, 2009, 2010 +// 2006, 2007, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -1046,7 +1046,14 @@ _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { } _GLIBCXX_CONSTEXPR complex(float __r = 0.0f, float __i = 0.0f) - : _M_value(__r + __i * 1.0fi) { } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + : _M_value{ __r, __i } { } +#else + { + __real__ _M_value = __r; + __imag__ _M_value = __i; + } +#endif explicit _GLIBCXX_CONSTEXPR complex(const complex&); explicit _GLIBCXX_CONSTEXPR complex(const complex&); @@ -1186,7 +1193,14 @@ _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { } _GLIBCXX_CONSTEXPR complex(double __r = 0.0, double __i = 0.0) - : _M_value(__r + __i * 1.0i) { } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + : _M_value{ __r, __i } { } +#else + { + __real__ _M_value = __r; + __imag__ _M_value = __i; + } +#endif _GLIBCXX_CONSTEXPR complex(const complex& __z) : _M_value(__z.__rep()) { } @@ -1328,7 +1342,14 @@ _GLIBCXX_CONSTEXPR complex(long double __r = 0.0L, long double __i = 0.0L) - : _M_value(__r + __i * 1.0Li) { } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + : _M_value{ __r, __i } { } +#else + { + __real__ _M_value = __r; + __imag__ _M_value = __i; + } +#endif _GLIBCXX_CONSTEXPR complex(const complex& __z) : _M_value(__z.__rep()) { } Index: testsuite/26_numerics/complex/cons/48760.cc =================================================================== --- testsuite/26_numerics/complex/cons/48760.cc (revision 0) +++ testsuite/26_numerics/complex/cons/48760.cc (revision 0) @@ -0,0 +1,56 @@ +// 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 +#include + +template + void do_test01() + { + bool test __attribute__((unused)) = true; + + if (std::numeric_limits::has_quiet_NaN) + { + std::complex c1(T(0), std::numeric_limits::quiet_NaN()); + VERIFY( c1.real() == T(0) ); + VERIFY( std::isnan(c1.imag()) ); + + std::complex c2(std::numeric_limits::quiet_NaN(), T(0)); + VERIFY( std::isnan(c2.real()) ); + VERIFY( c2.imag() == T(0) ); + + std::complex c3(std::numeric_limits::quiet_NaN(), + std::numeric_limits::quiet_NaN()); + VERIFY( std::isnan(c3.real()) ); + VERIFY( std::isnan(c3.imag()) ); + } + } + +// libstdc++/48760 +void test01() +{ + do_test01(); + do_test01(); + do_test01(); +} + +int main() +{ + test01(); + return 0; +} Index: testsuite/26_numerics/complex/cons/48760_c++0x.cc =================================================================== --- testsuite/26_numerics/complex/cons/48760_c++0x.cc (revision 0) +++ testsuite/26_numerics/complex/cons/48760_c++0x.cc (revision 0) @@ -0,0 +1,58 @@ +// { 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 +#include + +template + void do_test01() + { + bool test __attribute__((unused)) = true; + + if (std::numeric_limits::has_quiet_NaN) + { + std::complex c1(T(0), std::numeric_limits::quiet_NaN()); + VERIFY( c1.real() == T(0) ); + VERIFY( std::isnan(c1.imag()) ); + + std::complex c2(std::numeric_limits::quiet_NaN(), T(0)); + VERIFY( std::isnan(c2.real()) ); + VERIFY( c2.imag() == T(0) ); + + std::complex c3(std::numeric_limits::quiet_NaN(), + std::numeric_limits::quiet_NaN()); + VERIFY( std::isnan(c3.real()) ); + VERIFY( std::isnan(c3.imag()) ); + } + } + +// libstdc++/48760 +void test01() +{ + do_test01(); + do_test01(); + do_test01(); +} + +int main() +{ + test01(); + return 0; +} --------------070906050301080203080605--