3 ms·
Blame the CPU makers. Fun fact: in Zig, unsigned overflow are undefined too.
by renox 3y ago
Blame the CPU makers.
Fun fact: in Zig, unsigned overflow are undefined too.
- kps 3y agoZig does have modular `+%` and saturating `+|` operators, as well as `@addWithOverflow()`, though. You get to choose what happens on overflow; if you don't, the compiler gets to.
- loup-vaillant 3y agoI’ll blame CPU makers when you can name one CPU in current use that isn’t bog standard 2’s complement that wraps around by default. About Zig, you probably meant implementation defined, or at the very worst unspecified. In C standard parlance those aren’t undefined at all. They can’t encrypt your hard drive just because you relied on them. Undefined behaviour however, can. And does, when UB happens to enable an arbitrary code execution vulnerability.