logoalt Hacker News

codedokode • today at 4:46 PM • 2 replies • view on HN

Integer underflow again. Programming languages should trap on integer overflows and not ignore them. Don't care about legacy CPUs not having a trap for this - they will go sooner or later.


Replies

deathanatos • today at 5:35 PM

Rust has a compile time option, though to my immense disappointment, it defaults to on only in debug mode. (You can opt into it for release, if desired.)

Python simply can't overflow, since its integral type is not a fixed width.

But it is the sort of correctness thing that I do wish languages would pay more attention to.

➕ show 2 replies