Skip to content

Nix integer overflow is implemented by undefined behavior #10968

@roberth

Description

@roberth

Describe the bug

See https://git.lix.systems/lix-project/lix/issues/423

  1. Nix currently behaves by overflowing.
  2. Overflowing is UB, but predictable, so a few users might rely on it without difficulties such as impurities showing through hashes and substitution

Steps To Reproduce

nix-repl> 500000000*50000000000
6553255926290448384

Expected behavior

I'm inclined to make it throw instead.
If that is a problem, we may revisit. Have some thoughts on how; see https://git.lix.systems/lix-project/lix/issues/423#issuecomment-4604

nix-env --version output

Additional context

Priorities

Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    buglanguageThe Nix expression language; parser, interpreter, primops, evaluation, etc
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions