From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 126576 invoked by alias); 22 Oct 2016 15:35:02 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 126539 invoked by uid 89); 22 Oct 2016 15:35:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Wrap X-HELO: mx1.redhat.com Subject: Re: [PATCH] Define iszero as a function template for C++ [BZ #20715] To: Joseph Myers References: <2b2fa3c4-5bd6-4025-717f-fe2e2ee19555@redhat.com> Cc: GNU C Library From: Florian Weimer Message-ID: Date: Sat, 22 Oct 2016 15:35:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------5D97ADC81F61ECF19D063F63" X-SW-Source: 2016-10/txt/msg00376.txt.bz2 This is a multi-part message in MIME format. --------------5D97ADC81F61ECF19D063F63 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-length: 918 On 10/21/2016 06:31 PM, Florian Weimer wrote: > On 10/21/2016 06:23 PM, Joseph Myers wrote: >> On Fri, 21 Oct 2016, Florian Weimer wrote: >> >>> On 10/21/2016 06:12 PM, Joseph Myers wrote: >>>> On Fri, 21 Oct 2016, Florian Weimer wrote: >>>> >>>>> Tested on x86_64, ppc64, ppc64le, s390x, aarch64. >>>>> >>>>> I'm not sure if the new test is particularly meaningful, but at >>>>> least it >>>>> catches syntax errors in . >>>> >>>> This seems fine to me (with negative zero included in the testcase), >>> >>> Oh. How do I get a negative zero? Would T{-0.0} be sufficient? Or >>> should I >> >> Yes, T{-0.0} or -T{0} should suffice. > > Thanks. Here is what I've committed. Everything is optimized away > anyway (but I deliberately introduced a bug to make sure the test still > tests something). I had to commit the attached follow-on fix to make extern "C" { #include } work again. Florian --------------5D97ADC81F61ECF19D063F63 Content-Type: text/x-patch; name="iszero2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="iszero2.patch" Content-length: 932 math.h: Wrap C++ bits in extern "C++" It is still common to include system header files in an extern "C" block. This means that exiting 's own extern "C" block is not sufficient to get back to C++ mode. Use an extern "C++" wrapper instead. 2016-10-22 Florian Weimer * math/math.h [__cplusplus] (iszero): Wrap C++ bits in extern "C++", to override a potential extern "C" directive around the header file inclusion. diff --git a/math/math.h b/math/math.h index 0220d08..7c0c709 100644 --- a/math/math.h +++ b/math/math.h @@ -342,7 +342,7 @@ enum # define iszero(x) (((__typeof (x)) (x)) == 0) # endif # else /* __cplusplus */ -__END_DECLS +extern "C++" { template inline bool iszero (__T __val) { @@ -352,7 +352,7 @@ iszero (__T __val) return __val == 0; # endif } -__BEGIN_DECLS +} /* extern C++ */ # endif /* __cplusplus */ #endif /* Use IEC_60559_BFP_EXT. */ --------------5D97ADC81F61ECF19D063F63--