From patchwork Mon Jan 11 15:45:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 59550 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2188668lbb; Mon, 11 Jan 2016 07:45:49 -0800 (PST) X-Received: by 10.98.19.148 with SMTP id 20mr10739069pft.22.1452527149471; Mon, 11 Jan 2016 07:45:49 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g15si29225554pfg.147.2016.01.11.07.45.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jan 2016 07:45:49 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-66153-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libc-alpha-return-66153-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-66153-patch=linaro.org@sourceware.org; dkim=pass header.i=@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=GNb TGLqhiHbaie9sEvB2pOvFRCAAuxI2rb8/NUDx+E5HTKK6d2vWBP4tdDC+FBwtoLB FG9tZzQbG1bc73tlfpez1pZFbAXA8kZALEfdXYEaIzhzUY0CdaLGmVdrb/AcKDXW XXEgq1Vumj6ejVBfof1xZzIA4yHpPn1Z8JBFV3Ac= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; s=default; bh=C4s16XcQX xBwEjCyEoD8jR1VWsA=; b=e8Qu4L4s425yqSZU1HWoj+RaaLqsfpQC65O6nrCO/ onGzFLOqlQrE+eQ446B4gMn+v9U/0BLd+q8pIFWRKYl8gtcNJOLIXozsJMxk4PS2 bIfk0vPewJWeHHlJNfvq+8+FWLeTWkj8DA1YdLeOiaZrqLmTP2yf9preleRs2c/g a0= Received: (qmail 102618 invoked by alias); 11 Jan 2016 15:45:38 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 102598 invoked by uid 89); 11 Jan 2016 15:45:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=U*jwakely.gcc, sk:jwakely, jwakelygccgmailcom, jwakely.gcc@gmail.com X-HELO: mail-yk0-f178.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; bh=y/Rrrw+5Ez3spxa1LuU1W/W8YosBbz7korQr330Yngo=; b=PxjzAFa6QBoZKVXeU+DU0NxAtrMGvBvuLEaBilK/nmrj+D7uH7IMb9OO9j6CZK74zY IHMReTWopvevDjWcGTcwfkDGV7NUcQcvWhbolz/AtioFjwB31p9r9+ZKvvNesvMVE1AJ 0bTYmM8/2TgdOy8IFo3U2GZuWnjvGWDEObVgVEruKG0nurSL2QWuN1y08/9zOq1Fvoql UdbpdhqkpP1pM8Q1ly2ccDYymP5phP5pJhO34R2hrmtqjznTX7Efb8y5yKEsUx+MWwRl rA5ZmU8FThFU3CU4ictbdbPAQeoWPCq003ctKY4lyQKs295hd3LsQNBGOOU0lZNU23sB C8/Q== X-Gm-Message-State: ALoCoQnNQCtpVPnAI2umhJMSMqoVB7BSlHKJQtrfQjZ80G5YMBxQCFJFP85cOBZ1SSj56Z0UVhgiqkiaQ/++ag8GLe9hefebuA== X-Received: by 10.129.88.193 with SMTP id m184mr79728230ywb.332.1452527134048; Mon, 11 Jan 2016 07:45:34 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH] Fix isinf/isnan declaration conflict with C++11 Date: Mon, 11 Jan 2016 13:45:21 -0200 Message-Id: <1452527121-28270-1-git-send-email-adhemerval.zanella@linaro.org> MIME-Version: 1.0 GLIBC declares isinf and isnan as expected by Unix98 and for C99 programs these functions are hidden by the genericis inf and isnan macros. However C++11 defines isinf and isnan with the same semantics as C99 but requires that they are functions not macros (C++11 26.8 [c.math] paragraph 10). This then results in a conflict for perfectly valid C++11 programs: -- using std::isinf; using std::isnan; double d1 = isinf(1.0); double d2 = isnan(1.0); d.cc:3:12: error: ‘constexpr bool std::isinf(double)’ conflicts with a previous declaration using std::isinf; [...] /usr/include/bits/mathcalls.h:201:1: note: previous declaration ‘int isinf(double)’ __MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__)); [...] -- This patch fixes the prototypes by leaving the obsolete functions defined for C++98 code (since they do not conflict with any standard function in C++98), however preventing them on C++11. No issues found in libstdc++ tests and check on x86_64 and i686 with glibc testsuite. [BZ #19439] * math/bits/mathcalls.h [!__cplusplus || __cplusplus < 201103L] (isinf): Do not declare prototype. [!__cplusplus || __cplusplus < 201103L] (isnan): Likewise. Patch by Jonathan Wakely . --- ChangeLog | 9 +++++++++ math/bits/mathcalls.h | 4 ++++ 2 files changed, 13 insertions(+) -- 1.9.1 diff --git a/math/bits/mathcalls.h b/math/bits/mathcalls.h index b82c373..a48345d 100644 --- a/math/bits/mathcalls.h +++ b/math/bits/mathcalls.h @@ -196,9 +196,11 @@ __MATHDECL_1 (int,__finite,, (_Mdouble_ __value)) __attribute__ ((__const__)); _Mdouble_END_NAMESPACE #ifdef __USE_MISC +# if !defined __cplusplus || __cplusplus < 201103L /* Conflicts with C++11. */ /* Return 0 if VALUE is finite or NaN, +1 if it is +Infinity, -1 if it is -Infinity. */ __MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__)); +# endif /* Return nonzero if VALUE is finite and not NaN. */ __MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__)); @@ -230,8 +232,10 @@ __END_NAMESPACE_C99 __MATHDECL_1 (int,__isnan,, (_Mdouble_ __value)) __attribute__ ((__const__)); #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K) +# if !defined __cplusplus || __cplusplus < 201103L /* Conflicts with C++11. */ /* Return nonzero if VALUE is not a number. */ __MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__)); +# endif #endif #if defined __USE_MISC || (defined __USE_XOPEN && __MATH_DECLARING_DOUBLE)