bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Failed float self test on OS X 10.5 with PowerPC


From: Jeffrey Walton
Subject: Failed float self test on OS X 10.5 with PowerPC
Date: Sun, 3 May 2020 00:35:29 -0400

Hi Everyone/Bruno,

I think Bruno and I were talking about this for a while back in 2018
or 2019. Gnulib was failing one self test due to floats on OS X 10.5
on PowerPC....

Here is the OS X man page on floats:
https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/float.3.html
.

The man page is wrong when it says "On PowerPC macs, by default the
type long double is mapped to IEEE-754 double precision, described
above." By default it maps to the 128-bit long doubles.

It looks like -mlong-double-128 is engaged by default, and we need
-mlong-double-64 to get to the behavior the man page details and
Gnulib expects.

$ cat test.c
#include <stdio.h>
#include <float.h>
#include <stdint.h>

int main(int argc, char* argv[])
{
    int lb[] = {
        LDBL_MANT_DIG, LDBL_MIN_EXP, LDBL_MAX_EXP,
        LDBL_DIG, LDBL_MIN_10_EXP, LDBL_MAX_10_EXP
    };

    printf("sizeof(long double): %d\n", (int)sizeof(long double));
    printf("LDBL_MANT_DIG: %d\n", lb[0]);
    printf("LDBL_MIN_EXP: %d\n", lb[1]);
    printf("LDBL_MAX_EXP: %d\n", lb[2]);
    printf("LDBL_DIG: %d\n", lb[3]);
    printf("LDBL_MIN_10_EXP: %d\n", lb[4]);
    printf("LDBL_MAX_10_EXP: %d\n", lb[5]);
}

$ gcc -O1 test.c -o test.exe
$ ./test.exe
sizeof(long double): 16
LDBL_MANT_DIG: 106
LDBL_MIN_EXP: -968
LDBL_MAX_EXP: 1024
LDBL_DIG: 31
LDBL_MIN_10_EXP: -291
LDBL_MAX_10_EXP: 308

$ gcc -O1 -mlong-double-128 test.c -o test.exe
$ ./test.exe
sizeof(long double): 16
LDBL_MANT_DIG: 106
LDBL_MIN_EXP: -968
LDBL_MAX_EXP: 1024
LDBL_DIG: 31
LDBL_MIN_10_EXP: -291
LDBL_MAX_10_EXP: 308

$ gcc -O1 -mlong-double-64 test.c -o test.exe
$ ./test.exe
sizeof(long double): 8
LDBL_MANT_DIG: 53
LDBL_MIN_EXP: -1021
LDBL_MAX_EXP: 1024
LDBL_DIG: 15
LDBL_MIN_10_EXP: -307
LDBL_MAX_10_EXP: 308

I don't know if something should be done proactively. Should Gnulib
fail to configure without -mlong-double-64? Or maybe, should Gnulib
just add -mlong-double-64 when needed?

Jeff



reply via email to

[Prev in Thread] Current Thread [Next in Thread]