Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

On the PDP-11, overflow would have trapped.

On the DEC VAX, overflow could be set to trap, based on a bit mask at the beginning of each function, but that was not the case on the PDP-11. Nobody used that feature. I once modified the C compiler for the VAX to make integer overflow trap, and rebuilt standard utilities. Most of them trapped on integer overflow.

If you want arithmetic to wrap, you should have to write something like

    n := (n + 1) mod (2^32);
Let the optimizer figure out there's a cheap way to do that.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: