-
Notifications
You must be signed in to change notification settings - Fork 589
Description
This is a bug report for perl from [email protected],
generated with the help of perlbug 1.43 running under perl 5.38.0.
Module: POSIX
Description
Perl 5.38.x (or, at least, it's POSIX module) seem to break floating-point
constants, making 0 < 0.5 false in some locales after setlocale() in BEGIN block.
Verified to work ok: v5.36.3
Verified as buggy: v5.38.0, v5.38.2
Steps to Reproduce
If I set
LC_NUMERIC=ru_RU.UTF-8
in the environment, this script prints "not ok" under Perl 5.38.x, but "ok" under Perl 5.36.3:
BEGIN {
use POSIX qw(locale_h);
setlocale(LC_NUMERIC, '');
}
print "perl: $^V\n";
if (0 < 0.5) {
print "ok\n";
} else {
print "not ok\n";
}
Of course, reproduction requires corresponding locale to be present in the system. On my machine, uncommenting corresponding locale name (ru_RU.UTF-8) in /etc/locale.gen and running sudo locale-gen does the trick.
Expected behavior
Floating-point constants should work with any locales. Yes, in ru_RU.UTF-8 locale
the decimal separator is ",", not ".". But that should not affect parsing the
source code itself. Besides, what are we supposed to write instead, 0 < 0,5 ? That would mean
something else!
To sum up: I expected 0 < 0.5 to be true in any locale, even after setlocale()
in the BEGIN block.
Originally this behaviour was found under Ubuntu 24.04 (which has Perl v5.38.2 shipped as package) with some other module doing "use POSIX / setlocale in the BEGIN block" trick for some other reasons, so it does affect real-world usage.
Flags
- category=library
- severity=high
- module=POSIX
Perl configuration
Site configuration information for perl 5.38.0:
Configured by ashutosh at Fri Apr 26 19:37:42 MSK 2024.
Summary of my perl5 (revision 5 version 38 subversion 0) configuration:
Commit id: 76298ae68aa7796f0ffc05095b127d23f4b2de8f
Platform:
osname=linux
osvers=6.5.0-26-generic
archname=x86_64-linux
uname='linux z 6.5.0-26-generic #26~22.04.1-ubuntu smp preempt_dynamic tue mar 12 10:22:43 utc 2 x86_64 x86_64 x86_64 gnulinux '
config_args='-des -Dprefix=/home/ashutosh/bin/perl5-38-0'
hint=recommended
useposix=true
d_sigaction=define
useithreads=undef
usemultiplicity=undef
use64bitint=define
use64bitall=define
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
Compiler:
cc='cc'
ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
optimize='-O2'
cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
ccversion=''
gccversion='11.4.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='double'
nvsize=8
Off_t='off_t'
lseeksize=8
alignbytes=8
prototype=define
Linker and Libraries:
ld='cc'
ldflags =' -fstack-protector-strong -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib/x86_64-linux-gnu /usr/lib /usr/lib64
libs=-lpthread -ldl -lm -lcrypt -lutil -lc
perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
libc=/lib/x86_64-linux-gnu/libc.so.6
so=so
useshrplib=false
libperl=libperl.a
gnulibc_version='2.35'
Dynamic Linking:
dlsrc=dl_dlopen.xs
dlext=so
d_dlsymun=undef
ccdlflags='-Wl,-E'
cccdlflags='-fPIC'
lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'
---
@INC for perl 5.38.0:
/home/ashutosh/perl5/lib/perl5/x86_64-linux
/home/ashutosh/perl5/lib/perl5
/home/ashutosh/bin/perl5-38-0/lib/site_perl/5.38.0/x86_64-linux
/home/ashutosh/bin/perl5-38-0/lib/site_perl/5.38.0
/home/ashutosh/bin/perl5-38-0/lib/5.38.0/x86_64-linux
/home/ashutosh/bin/perl5-38-0/lib/5.38.0
---
Environment for perl 5.38.0:
HOME=/home/ashutosh
LANG=en_US.UTF-8
LANGUAGE=
LC_ADDRESS=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_NUMERIC=en_US.UTF-8
LC_PAPER=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_TIME=en_GB.UTF-8
LD_LIBRARY_PATH=/home/ashutosh/pg/master/ci_install/lib:/usr/local/lib:/opt/icu70.1/lib:/opt/icu69.1/lib:/opt/icu53.1/lib
LOGDIR (unset)
PATH=/home/ashutosh/pg/master/ci_install/bin:/opt/valgrind/bin:/home/ashutosh/perl5/bin:/home/ashutosh/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/opt/gdb-13/bin:/home/ashutosh/bin:/usr/lib/ccache:/home/ashutosh/.local/bin:/home/ashutosh/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PERL5LIB=/home/ashutosh/perl5/lib/perl5
PERL_BADLANG (unset)
PERL_LOCAL_LIB_ROOT=/home/ashutosh/perl5
PERL_MB_OPT=--install_base "/home/ashutosh/perl5"
PERL_MM_OPT=INSTALL_BASE=/home/ashutosh/perl5
SHELL=/bin/bash