Skip to content

POSIX shouldn't test signbit(NAN) #21533

Closed
@rkennedy

Description

@rkennedy

Module: POSIX

Description
ext/POSIX/t/math.t includes an assertion about signbit(NAN), and it fails while I'm trying to build v5.38.0:

ext/POSIX/t/math ................................................. #   Failed test 'signbit(NAN)'
#   at t/math.t line 296.
# Looks like you failed 1 test of 151.

It's this assertion:

ok(!signbit(NAN), "signbit(NAN)");

The assertion fails on my Solaris x86 system. The underlying C signbit function exhibits the same behavior.

#include <stdio.h>
#include <math.h>
int main(void) {
    printf("NaN sign bit: %d\n", signbit(NAN));
    return 0;
}

That prints NaN sign bit: 1. (On my Solaris Sparc system, and on my RHEL x86_64 host, it reports "0" instead, and Perl's signbit test passes.)

Steps to Reproduce

./Configure -Dcc=/bin/cc -des -Dusethreads -Duseshrplib=false -Dnoextensions=ODBM_File
make
make test TEST_FILES=../ext/POSIX/t/math.t

Expected behavior
This particular assertion shouldn't be present. POSIX does not specify the precise value of NAN. Although NAN values may have sign bits, they do not have signs, per se, so it's wrong to assert that the value of NAN's sign bit should have any particular value.

This is somewhat related to issue #18473, and especially to PR #18590, where the failing assertion was added.

Perl configuration

Summary of my perl5 (revision 5 version 38 subversion 0) configuration:
  Commit id: 76298ae68aa7796f0ffc05095b127d23f4b2de8f
  Platform:
    osname=solaris
    osvers=2.10
    archname=i86pc-solaris-thread-multi
    uname='sunos solx8610u11 5.10 generic_147148-26 i86pc i386 i86pc '
    config_args='-Dcc=/bin/cc -des -Dusethreads -Duseshrplib=false -Dnoextensions=ODBM_File'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=undef
    use64bitall=undef
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='/bin/cc'
    ccflags ='-D_REENTRANT -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    optimize='-O'
    cppflags='-D_REENTRANT'
    ccversion='Studio 12.6 Sun C 5.15 SunOS_i386 2017/05/30'
    gccversion=''
    gccosandvers=''
    intsize=4
    longsize=4
    ptrsize=4
    doublesize=8
    byteorder=1234
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=12
    longdblkind=3
    ivtype='long'
    ivsize=4
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=4
    prototype=define
  Linker and Libraries:
    ld='/bin/cc'
    ldflags =' -L/usr/lib -L/usr/ccs/lib -L/opt/developerstudio12.6/lib/compilers/sse2 -L/opt/developerstudio12.6/lib/compilers -L/lib '
    libpth=/usr/lib /usr/ccs/lib /opt/developerstudio12.6/lib/compilers/sse2 /opt/developerstudio12.6/lib/compilers /lib
    libs=-lpthread -lsocket -lnsl -ldl -lm -lc
    perllibs=-lpthread -lsocket -lnsl -ldl -lm -lc
    libc=/lib/libc.so
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags='-KPIC'
    lddlflags='-G -L/usr/lib -L/usr/ccs/lib -L/opt/developerstudio12.6/lib/compilers/sse2 -L/opt/developerstudio12.6/lib/compilers -L/lib'


Characteristics of this binary (from libperl):
  Compile-time options:
    HAS_LONG_DOUBLE
    HAS_STRTOLD
    HAS_TIMES
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_HASH_FUNC_ZAPHOD32
    PERL_HASH_USE_SBOX32
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
    USE_REENTRANT_API
  Built under solaris
  Compiled at Sep 28 2023 14:42:16
  @INC:
    lib
    /opt/lib/perl5/site_perl/5.38.0/i86pc-solaris-thread-multi
    /opt/lib/perl5/site_perl/5.38.0
    /opt/lib/perl5/5.38.0/i86pc-solaris-thread-multi
    /opt/lib/perl5/5.38.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions