Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[powerpc64] perl prints subnormal doubledoubles incorrectly. #16507

Open
p5pRT opened this issue Apr 14, 2018 · 3 comments
Open

[powerpc64] perl prints subnormal doubledoubles incorrectly. #16507

p5pRT opened this issue Apr 14, 2018 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 14, 2018

Migrated from rt.perl.org#133110 (status was 'open')

Searchable as RT133110$

@p5pRT
Copy link
Author

p5pRT commented Apr 14, 2018

From @sisyphus

Hi,

I'm running perl-5.27.10, but the same issue is evident in perl-5.20.0 and
perl-5.26.0.

For perls built with -Duselongdouble on my powerpc64 box the 'long double'
is a 'doubledouble'.
As an example of the problem​:

$ perl -le 'print 2 ** -1074;'
4.450147717014402766180465434665e-308

But this is the same as 2 ** -1021​:

$ perl -le 'print 2 ** -1021;'
4.450147717014402766180465434665e-308

Similarly for all other subnormals I tried, perl's print and printf( "%e",
..) functions output values that are off by a factor of 2**53.
Using printf's "%a" formatting produces the correct result.

Also, we see that the value being held by the NV is correct when we unpack
it​:
$ perl -le ' print scalar reverse unpack "h*", pack "F<", 2 ** -1074;'
00000000000000010000000000000000

This is clearly the pair of doubles DBL_DENORM_MIN and zero - which is the
smallest positive value that the doubledouble can hold.

Cheers,
Rob

$ perl -V
Summary of my perl5 (revision 5 version 27 subversion 10) configuration​:

  Platform​:
  osname=linux
  osvers=3.2.0-4-powerpc64
  archname=ppc64-linux-thread-multi-ld
  uname='linux debian-sis 3.2.0-4-powerpc64 #1 smp debian 3.2.78-1 ppc64
gnulinux '
  config_args='-des -Uversiononly -Dcc=gcc -m64 -Dprefix=/home/sisyphus-sis/perl-5.27.10-ld
-Dusedevel -Duselongdouble -Dusethreads -Duse64bitint'
  hint=recommended
  useposix=true
  d_sigaction=define
  useithreads=define
  usemultiplicity=define
  use64bitint=define
  use64bitall=define
  uselongdouble=define
  usemymalloc=n
  default_inc_excludes_dot=define
  bincompat5005=undef
  Compiler​:
  cc='gcc -m64'
  ccflags
='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
  optimize='-O1'
  cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe
-fstack-protector -I/usr/local/include'
  ccversion=''
  gccversion='4.6.3'
  gccosandvers=''
  intsize=4
  longsize=8
  ptrsize=8
  doublesize=8
  byteorder=87654321
  doublekind=4
  d_longlong=define
  longlongsize=8
  d_longdbl=define
  longdblsize=16
  longdblkind=6
  ivtype='long'
  ivsize=8
  nvtype='long double'
  nvsize=16
  Off_t='off_t'
  lseeksize=8
  alignbytes=16
  prototype=define
  Linker and Libraries​:
  ld='gcc -m64'
  ldflags =' -fstack-protector -L/usr/local/lib'
  libpth=/usr/local/lib /usr/lib/gcc/powerpc-linux-gnu/4.6/include-fixed
/usr/lib /lib/powerpc-linux-gnu /lib/../lib /usr/lib/powerpc-linux-gnu
/usr/lib/../lib /lib /lib64 /usr/lib64
  libs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
  perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
  libc=libc-2.13.so
  so=so
  useshrplib=false
  libperl=libperl.a
  gnulibc_version='2.13'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs
  dlext=so
  d_dlsymun=undef
  ccdlflags='-Wl,-E'
  cccdlflags='-fPIC'
  lddlflags='-shared -O1 -L/usr/local/lib -fstack-protector'

Characteristics of this binary (from libperl)​:
  Compile-time options​:
  HAS_TIMES
  MULTIPLICITY
  PERLIO_LAYERS
  PERL_COPY_ON_WRITE
  PERL_DONT_CREATE_GVSV
  PERL_IMPLICIT_CONTEXT
  PERL_MALLOC_WRAP
  PERL_OP_PARENT
  PERL_PRESERVE_IVUV
  PERL_USE_DEVEL
  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 linux
  Compiled at Apr 3 2018 20​:52​:50
  @​INC​:
  /home/sisyphus-sis/perl-5.27.10-ld/lib/site_perl/5.27.10/ppc64-linux-thread-multi-ld
  /home/sisyphus-sis/perl-5.27.10-ld/lib/site_perl/5.27.10
  /home/sisyphus-sis/perl-5.27.10-ld/lib/5.27.10/ppc64-linux-thread-multi-ld
  /home/sisyphus-sis/perl-5.27.10-ld/lib/5.27.10

@p5pRT
Copy link
Author

p5pRT commented Feb 6, 2019

From @sisyphus

On Fri, 13 Apr 2018 22​:39​:50 -0700, sisyphus wrote​:

$ perl -le 'print 2 ** -1074;'
4.450147717014402766180465434665e-308

C's printf() produces the same incorrect output - so, either perl and C are making the same mistake, or perl is just passing on the value that C provides.

I suspect the latter - ie that this is NOT a bug in Perl.

I'm using gcc-4.6.3 and libc-2.13, which is fairly old stuff.

Cheers,
Rob

@p5pRT
Copy link
Author

p5pRT commented Feb 6, 2019

The RT System itself - Status changed from 'new' to 'open'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants