develooper Front page | perl.perl5.porters | Postings from July 2016

Re: [perl #128665] Cygwin: trunc(2.75) is broken somewhere on longdouble builds

Thread Previous | Thread Next
From:
Dan Collins
Date:
July 18, 2016 18:45
Subject:
Re: [perl #128665] Cygwin: trunc(2.75) is broken somewhere on longdouble builds
Message ID:
CA+tt54Lijq4tCgQSWfj26uDiQQaqk7SkVKYzUWWrx1AU5M78rQ@mail.gmail.com
In particular, trunc() seems to be using round towards nearest, ties to
even, rather than round towards zero.

On Mon, Jul 18, 2016 at 1:34 PM, Dan Collins <perlbug-followup@perl.org>
wrote:

> # New Ticket Created by  Dan Collins
> # Please include the string:  [perl #128665]
> # in the subject line of all future correspondence about this issue.
> # <URL: https://rt.perl.org/Ticket/Display.html?id=128665 >
>
>
> Hello!
>
> I'm seeing the following test failure on Cygwin long double builds.
> Threads are not required, building with the following is adequate:
>
> ./Configure -Dusedevel -des -Duselongdouble -Accflags=-D_GNU_SOURCE
> -Alibswanted=cygwin && make test_prep
>
> The two -A on the Configure line are workarounds to RT #128358 and RT
> #128637
>
> dcollins@DESKTOP-ER38TCQ ~/perlstable
> $ ./perl -Ilib
> use strict;
>
> use POSIX ':math_h_c99';
> use POSIX ':nan_payload';
> use Test::More;
>
> is(trunc(2.25), 2, "trunc 2.25");
> is(trunc(-2.25), -2, "trunc -2.25");
> is(trunc(2.5), 2, "trunc 2.5");
> is(trunc(-2.5), -2, "trunc -2.5");
> is(trunc(2.75), 2, "trunc 2.75");
> is(trunc(-2.75), -2, "trunc -2.75");
> is(getpayload(nan(1234.567)), 1234, "nan (trunc) + getpayload");
> ok 1 - trunc 2.25
> ok 2 - trunc -2.25
> ok 3 - trunc 2.5
> ok 4 - trunc -2.5
> not ok 5 - trunc 2.75
> #   Failed test 'trunc 2.75'
> #   at - line 11.
> #          got: '3'
> #     expected: '2'
> not ok 6 - trunc -2.75
> #   Failed test 'trunc -2.75'
> #   at - line 12.
> #          got: '-3'
> #     expected: '-2'
> not ok 7 - nan (trunc) + getpayload
> #   Failed test 'nan (trunc) + getpayload'
> #   at - line 13.
> #          got: '1235'
> #     expected: '1234'
> # Tests were run but no plan was declared and done_testing() was not seen.
>
> dcollins@DESKTOP-ER38TCQ ~/perlstable
> $ ./perl -Ilib -V
> Summary of my perl5 (revision 5 version 25 subversion 2) configuration:
>   Commit id: 8c4723656080526a8392690f30ec46d642de80ba
>   Platform:
>     osname=cygwin, osvers=2.5.1(0.29753), archname=cygwin-thread-multi-ld
>     uname='cygwin_nt-10.0 desktop-er38tcq 2.5.1(0.29753) 2016-04-21 22:14
> x86_64 cygwin '
>     config_args='-Dusedevel -des -Doptimize=-O3 -g -Dusethreads
> -Duselongdouble -Accflags=-D_GNU_SOURCE -Alibswanted=cygwin'
>     hint=recommended, useposix=true, d_sigaction=define
>     useithreads=define, usemultiplicity=define
>     use64bitint=define, use64bitall=define, uselongdouble=define
>     usemymalloc=n, bincompat5005=undef
>   Compiler:
>     cc='gcc', ccflags ='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__
> -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong
> -D_FORTIFY_SOURCE=2',
>     optimize='-O3 -g',
>     cppflags='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -D_GNU_SOURCE
> -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong'
>     ccversion='', gccversion='5.3.0', gccosandvers=''
>     intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678,
> doublekind=3
>     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16,
> longdblkind=3
>     ivtype='long', ivsize=8, nvtype='long double', nvsize=16,
> Off_t='off_t', lseeksize=8
>     alignbytes=16, prototype=define
>   Linker and Libraries:
>     ld='g++', ldflags =' -Wl,--enable-auto-import -Wl,--export-all-symbols
> -Wl,--enable-auto-image-base -fstack-protector-strong -L/usr/local/lib'
>     libpth=/usr/lib /usr/lib/../lib/../include/w32api /usr/local/lib /lib
>     libs=-lpthread -ldl -lcygwin
>     perllibs=-lpthread -ldl -lcygwin
>     libc=/usr/lib/libc.a, so=dll, useshrplib=true,
> libperl=cygperl5_25_2.dll
>     gnulibc_version=''
>   Dynamic Linking:
>     dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
>     cccdlflags=' ', lddlflags=' --shared  -Wl,--enable-auto-import
> -Wl,--export-all-symbols -Wl,--enable-auto-image-base -L/usr/local/lib
> -fstack-protector-strong'
>
>
> Characteristics of this binary (from libperl):
>   Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS
>                         PERL_COPY_ON_WRITE PERL_DONT_CREATE_GVSV
>                         PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
>                         PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
> PERL_OP_PARENT
>                         PERL_PRESERVE_IVUV PERL_USE_DEVEL
>                         PERL_USE_SAFE_PUTENV USE_64_BIT_ALL USE_64_BIT_INT
>                         USE_ITHREADS USE_LARGE_FILES USE_LOCALE
>                         USE_LOCALE_COLLATE USE_LOCALE_CTYPE
>                         USE_LOCALE_NUMERIC USE_LOCALE_TIME USE_LONG_DOUBLE
>                         USE_PERLIO USE_PERL_ATOF USE_REENTRANT_API
>   Built under cygwin
>   Compiled at Jul 18 2016 13:14:50
>   @INC:
>     lib
>     /usr/local/lib/perl5/site_perl/5.25.2/cygwin-thread-multi-ld
>     /usr/local/lib/perl5/site_perl/5.25.2
>     /usr/local/lib/perl5/5.25.2/cygwin-thread-multi-ld
>     /usr/local/lib/perl5/5.25.2
>     /usr/local/lib/perl5/site_perl
>     .
>
> --
> Respectfully,
> Dan Collins
>
>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About