logoalt Hacker News

throw-qqqqq • today at 8:01 AM • 1 reply • view on HN

> I consider it common knowledge TBH

For a seasoned C developer, I’d agree with you, but parent declares himself

> As someone who only writes C or C++ occasionally

… so I think it’s fair enough to not know such details.

C semantics has a few details that often surprise non-regulars, despite being such a small and simple language.


Replies

jamiejquinn • today at 8:25 AM

I appreciate Zig's approach, where the runtime complains when over/underflow occurs with the regular `+` operator but explicitly wraps with `+%` (or even saturates with `+|`). Takes a little getting used to (that and explicit unsigned/signed casts) but it's much clearer.

➕ show 1 reply