NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
11.45k stars 1.44k forks source link

Nix integer overflow is implemented by undefined behavior #10968

Open roberth opened 5 days ago

roberth commented 5 days ago

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 :+1: to issues you find important.

nixos-discourse commented 4 days ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-06-26-nix-team-meeting-minutes-156/47740/1