Hacker News new | ask | show | jobs
by bluGill 1126 days ago
I cannot think of a useful way to define signed overflow. I can make it do something, but at the end of the day no matter how you define it, if it happens in the real world your program has a bug.

Since we can be sure if it ever happens your code has a bug, making it undefined is a good thing: the compiler can then assume it doesn't happen and so back track to prove some other things can't happen and so make your program run a little faster.

1 comments

I'd much rather have a bug in my program than UB. At least the bug is easy to track down and fix, and is limited in scope to the line of code that contains the error.
You sacrifice speedy code for this case that probably won't even happen and so you probably won't have to debug anyway. Is it really worth it?