From patchwork Sun Nov 11 02:27:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 198231 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 F16C92C0084 for ; Sun, 11 Nov 2012 13:28:03 +1100 (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=1353205685; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=k+MeOUy Cm36GsQYv3jlPfs75Zj0=; b=C5AVuoUncZ7NdNGuViuF+ExRcCq3utpuGnjtMwo PHyZnlxYYxB2MowFSwPaNLjB+HM4FxImlm9EysRX6CDnjZW5M+MvZr7gEzf4/OQV UzHEYp7L+taX9szRYMBia9PhKx66hXc+fEWZ07RWgJ7QAt/PtY8ZiRPOdUoAQogj 2hMA= 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:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=P+tqHy02gs14sMlhKBeS43QheQlekZY1BRrXChpsgteDNUHxAeBzooqJnkXEQh QZCl3ep/QWrnE2JsHKw4d2z00dSeM/jrjrgqezh0tD/W0YNGS9zv3/0A9gQH20At vWM44uuhTqzaoYXbvG6rgcF5B9mm93pSmZfIU4bYimsSg=; Received: (qmail 5818 invoked by alias); 11 Nov 2012 02:27:59 -0000 Received: (qmail 5798 invoked by uid 22791); 11 Nov 2012 02:27:58 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 11 Nov 2012 02:27:52 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qAB2Rq29012263 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 10 Nov 2012 21:27:52 -0500 Received: from [10.3.113.77] (ovpn-113-77.phx2.redhat.com [10.3.113.77]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qAB2Rpdn026832; Sat, 10 Nov 2012 21:27:51 -0500 Message-ID: <509F0D27.8080408@redhat.com> Date: Sat, 10 Nov 2012 21:27:51 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121016 Thunderbird/16.0.1 MIME-Version: 1.0 To: gcc-patches List , libstdc++ Subject: libstdc++ PATCH to add abi tag to complex::real/imag 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 As mentioned in http://gcc.gnu.org/wiki/Cxx11AbiCompatibility, C++11 changes the return type of complex::real and imag, leading to a binary incompatibility between C++98 and C++11 code if the functions are used without inlining. This patch adds an ABI tag to the C++11 variants so that they have different mangled names. This does not change the exports from libstdc++. For the map void->iterator change, I think it would make sense to just unconditionally return an iterator; there's no binary compatibility issue with older code that expects it to return void, the problem is only with C++11 code calling a C++98 instantiation that returns void. For the other cases mentioned on that page, I think either we want to unify the two implementations (because we think they're compatible) or add ABI tags to the C++11 implementations. Is this patch OK for trunk? Does someone on the library team want to look at the other cases? commit be79353c10252bc99cac5f9d9ce045207e665238 Author: Jason Merrill Date: Sat Nov 10 13:10:15 2012 -0500 * include/std/complex (real, imag): Add ABI tag in C++11 mode. diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index f9221a8..24fa414 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -141,9 +141,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 387. std::complex over-encapsulated. + __attribute ((abi_tag ("cxx11"))) constexpr _Tp real() { return _M_real; } + __attribute ((abi_tag ("cxx11"))) constexpr _Tp imag() { return _M_imag; } #else @@ -1061,9 +1063,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 387. std::complex over-encapsulated. + __attribute ((abi_tag ("cxx11"))) constexpr float real() { return __real__ _M_value; } + __attribute ((abi_tag ("cxx11"))) constexpr float imag() { return __imag__ _M_value; } #else @@ -1210,9 +1214,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 387. std::complex over-encapsulated. + __attribute ((abi_tag ("cxx11"))) constexpr double real() { return __real__ _M_value; } + __attribute ((abi_tag ("cxx11"))) constexpr double imag() { return __imag__ _M_value; } #else @@ -1360,9 +1366,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 387. std::complex over-encapsulated. + __attribute ((abi_tag ("cxx11"))) constexpr long double real() { return __real__ _M_value; } + __attribute ((abi_tag ("cxx11"))) constexpr long double imag() { return __imag__ _M_value; } #else diff --git a/libstdc++-v3/testsuite/26_numerics/complex/abi_tag.cc b/libstdc++-v3/testsuite/26_numerics/complex/abi_tag.cc new file mode 100644 index 0000000..a845466 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/abi_tag.cc @@ -0,0 +1,25 @@ +// Test that the C++11 variants of real/imag have an ABI tag +// { dg-do compile } +// { dg-options -std=c++11 } + +#include + +// { dg-final { scan-assembler "_ZNKSt7complexIfE4realB5cxx11Ev" } } +float (std::complex::*p1)() const = &std::complex::real; +// { dg-final { scan-assembler "_ZNKSt7complexIdE4realB5cxx11Ev" } } +double (std::complex::*p2)() const = &std::complex::real; +// { dg-final { scan-assembler "_ZNKSt7complexIeE4realB5cxx11Ev" } } +long double (std::complex::*p3)() const + = &std::complex::real; +// { dg-final { scan-assembler "_ZNKSt7complexIiE4realB5cxx11Ev" } } +int (std::complex::*p4)() const = &std::complex::real; + +// { dg-final { scan-assembler "_ZNKSt7complexIfE4imagB5cxx11Ev" } } +float (std::complex::*p5)() const = &std::complex::imag; +// { dg-final { scan-assembler "_ZNKSt7complexIdE4imagB5cxx11Ev" } } +double (std::complex::*p6)() const = &std::complex::imag; +// { dg-final { scan-assembler "_ZNKSt7complexIeE4imagB5cxx11Ev" } } +long double (std::complex::*p7)() const + = &std::complex::imag; +// { dg-final { scan-assembler "_ZNKSt7complexIiE4imagB5cxx11Ev" } } +int (std::complex::*p8)() const = &std::complex::imag;