public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: C Howland <cc1964t@gmail.com>
Cc: newlib@sourceware.org
Subject: Re: [PATCH] newlib: switch to autoconf long double wider macro
Date: Tue, 21 Jun 2022 21:52:17 -0500	[thread overview]
Message-ID: <d79b941a-f5ef-f816-a695-bfde9c8d281f@cs.ucla.edu> (raw)
In-Reply-To: <Yes3VQw7yVT72ZLd@vapier>

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.


      reply	other threads:[~2022-06-22  2:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-21  5:04 Mike Frysinger
2022-01-21 11:27 ` Corinna Vinschen
2022-01-21 12:39   ` Mike Frysinger
2022-01-21 13:27     ` Corinna Vinschen
     [not found]       ` <DM3P110MB0522CE6B7AE8122C7172E18A9A5B9@DM3P110MB0522.NAMP110.PROD.OUTLOOK.COM>
2022-01-21 17:03         ` C Howland
2022-01-21 22:44           ` Mike Frysinger
2022-06-22  2:52             ` Paul Eggert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d79b941a-f5ef-f816-a695-bfde9c8d281f@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=cc1964t@gmail.com \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).