From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zimbra.cs.ucla.edu (zimbra.cs.ucla.edu [131.179.128.68]) by sourceware.org (Postfix) with ESMTPS id 971093857350 for ; Wed, 22 Jun 2022 02:52:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 971093857350 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cs.ucla.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cs.ucla.edu Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id A45E516016D; Tue, 21 Jun 2022 19:52:19 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id BszI657AvdID; Tue, 21 Jun 2022 19:52:18 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id D8DA316016E; Tue, 21 Jun 2022 19:52:18 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id oOeXkN8HxATX; Tue, 21 Jun 2022 19:52:18 -0700 (PDT) Received: from [192.168.0.205] (ip72-206-2-24.fv.ks.cox.net [72.206.2.24]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 8A24A16016D; Tue, 21 Jun 2022 19:52:18 -0700 (PDT) Message-ID: Date: Tue, 21 Jun 2022 21:52:17 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] newlib: switch to autoconf long double wider macro Content-Language: en-US To: C Howland References: <20220121050411.23094-1-vapier@gentoo.org> Cc: newlib@sourceware.org From: Paul Eggert In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jun 2022 02:52:21 -0000 On 1/21/22 16:44, Mike Frysinger wrote: > On 21 Jan 2022 12:03, C Howland wrote: > And a question about the test. There are two main segments in it: >> + long double const a[] = >> + { >> + 0.0L, DBL_MIN, DBL_MAX, DBL_EPSILON, >> + LDBL_MIN, LDBL_MAX, LDBL_EPSILON >> + }; >> + long double >> + f (long double x) >> + { >> + return ((x + (unsigned long int) 10) * (-1 / x) + a[0] >> + + (x ? f (x) : 'c')); >> + } >> + >> +int >> +main () >> +{ >> +static int test_array [1 - 2 * !((0 < ((DBL_MAX_EXP < LDBL_MAX_EXP) >> + + (DBL_MANT_DIG < LDBL_MANT_DIG) >> + - (LDBL_MAX_EXP < DBL_MAX_EXP) >> + - (LDBL_MANT_DIG < DBL_MANT_DIG))) >> + && (int) LDBL_EPSILON == 0 >> + )]; >> +test_array [0] = 0; >> +return test_array [0]; >> + >> + ; >> + return 0; >> +} >> >> What's the first part doing? Only the second part (main) is performing the >> size comparison. The first part is making sure you can use macros like DBL_MIN where constant expressions are required. Some old nonstandard compilers don't support that. >> Now a secondary item: the (int) LDBL_EPSILON == 0 term in the check >> is degenerate and does nothing. (By rule (from the standard) the cast to >> int discards the fraction so it will always be 0 and it becomes ... && 1.) That's true on standard compilers. But there may be old nonstandard compilers where (int) LDBL_EPSILON == 0 is not an integer constant expression, and that part detects the bug in those compilers.