Skip to content

[bug] Arithmetic: variable VALUE with leading zero is not treated as octal (x=010; $((x)) gives 10, GNU gives 8) #341

Closed

Description

@caomengxuan666

Found by gnusweep3 lane (cat4 a019/a053; WSL GNU Bash 5.3.0 oracle, worktree 0fe8d0f).

Repro:

x=010
echo $((x))          # GNU: 8   rubash: 10
i=010
echo $((i++)) $((i)) # GNU: 8 9  rubash: 10 11

GNU C owner: expr.c:1557 strlong() — documented contract at expr.c:1539: "0nnn -> base 8"; variable values are read through strlong when evaluated, so a stored leading-zero value re-parses as octal. (0x values already work in rubash — only the octal form diverges.)
Artifacts: target/issue-suites/results/gnusweep3/cat4/case/a019.* / a053.; minimal target/issue-suites/results/gnusweep3/probes/min/m07-octal-value.

Activity

  1. added
    bug
    gnu-baseline
    on Sep 30, 2026
  2. added a commit that references this issue on Sep 30, 2026
  3. caomengxuan666 commented on Sep 30, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by wt20/deepsweep (4bcd2b62): arithmetic values keep leading-zero octal (x=010 in $((x)) -> 8; strlong expr.c:1539/1557).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions