#14660·coreutils

tail: obsolete `+0` syntax underflows the skip count — prints nothing in release, aborts under overflow-checks

Author: leeeweeCreated Sep 18, 2026Updated Sep 18, 2026

tail's obsolete operand syntax (tail +N, tail +Nc) is parsed by a different path than the modern -n +N / -c +N flags, and that path never normalises a zero count. +0 therefore yields Signum::Positive(0) where -n +0 yields Signum::PlusZero, so unbounded_tail falls past its PlusZero | Positive(1) arm into the general Positive(count) arm and computes *count - 1 on a u64 zero.

In the default release build that underflow wraps to u64::MAX, tail skips every line, and the command silently prints nothing and exits 0 — GNU prints the entire input. Under -C overflow-checks=on the same expression aborts with attempt to subtract with overflow.

Steps to reproduce

Default release build — no crash, just the wrong answer:

bash
$ printf 'hello\nworld\n' | tail +0
$ echo $?
0

The same input under -C overflow-checks=on:

bash
$ printf 'hello\nworld\n' | tail +0

thread 'main' panicked at src/uu/tail/src/tail.rs:507:32:
attempt to subtract with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Aborted (core dumped)
$ echo $?
134

The byte form hits the sibling site in the same match:

bash
$ printf 'hello world' | tail +0c

thread 'main' panicked at src/uu/tail/src/tail.rs:533:32:
attempt to subtract with overflow
Aborted (core dumped)
$ echo $?
134

GNU behavior

bash
$ printf 'hello\nworld\n' | /usr/bin/tail +0
hello
world
$ echo $?
0