3 ms·
You’re you’re talking about the behaviour in C. Other langages are not C and can and do define other behaviours. Overflow is neither wrapping nor UB in Swift,
by masklinn 6y ago
You’re you’re talking about the behaviour in C. Other langages are not C and can and do define other behaviours.
Overflow is neither wrapping nor UB in Swift, it’s an error. Overflow is never UB in Rust but it might be wrapping or a panic. Overflow doesn’t exist in Python or Erlang. I think overflow is IB in Haskell.
You get the point: that signed overflow is UB and unsigned wraps in C has no bearing on what other langages do.
Swift traps on overflow, regardless of signedness.
- MaxBarraclough 6y agoThis thread is about C++.
- masklinn 6y agoThis sub-thread's starting point was literally a comment on Swift's behaviour. Unless C++ has drastically changed and now abruptly aborts on overflow.
- MaxBarraclough 6y agoI think you have this confused with the subthread under alblue's comment.