Package: coreutils
Version: 9.1-1
Severity: normal

Dear Maintainer,

We all know that for a 4-byte number the maximum value is 2^32-1,
and for an 8-byte one ‒ 2^64-1.

Even if we accept that for some bizzarre reason shuf
wants to be limited to 4-byte numbers,
then it should at least actually allow all of them.

Why, then:
-- >8 --
$ bc -q
2^32
4294967296
$ shuf -n1 -i 0-4294967296
shuf: invalid input range: ‘4294967296’: Value too large for defined data type
$ shuf -n1 -i 0-4294967295
shuf: invalid input range: ‘0-4294967295’
$ shuf -n1 -i 0-4294967294
2310362399
-- >8 --
and
-- >8 --
$ bc
2^64
18446744073709551616
$ shuf -n1 -i 0-18446744073709551616
shuf: invalid input range: ‘18446744073709551616’: Value too large for defined 
data type
$ shuf -n1 -i 0-18446744073709551615
shuf: invalid input range: ‘0-18446744073709551615’
$ shuf -n1 -i 0-18446744073709551614
16168582199677063639
-- >8 --

I mean, to hell with the highlighted bit of the range being different,
or there being no error string, apparently, right,
but why can't you just generate an integer?
Why is the operational range apparently one smaller than [0, 0xFFFFFFFF]?

This is disproportionately worse on ILP32 platforms given #1027412;
if this were just one off the end of 2^64, eh, who cares.

Best,
наб

-- System Information:
Debian Release: bookworm/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: x32 (x86_64)
Foreign Architectures: amd64, i386

Kernel: Linux 6.0.0-6-amd64 (SMP w/2 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, 
TAINT_UNSIGNED_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages coreutils depends on:
ii  libacl1      2.3.1-2
ii  libattr1     1:2.5.1-3
ii  libc6        2.36-6
ii  libgmp10     2:6.2.1+dfsg1-1.1
ii  libselinux1  3.4-1+b4

coreutils recommends no packages.

coreutils suggests no packages.

-- no debconf information

Attachment: signature.asc
Description: PGP signature

Reply via email to