3 ms·
You ( in the we sense of "you") cannot categorically say which is better. The decision between "keep on trucking" and crashing is a design choice, and will hav
by ArkyBeagle 10y ago
You ( in the we sense of "you") cannot categorically say which is better.
The decision between "keep on trucking" and crashing is a design choice, and will have to be balanced against other
considerations.
- mikeash 10y agoIf a language is going to have a default behavior, then it can't be a design choice that balances other considerations, because it has no idea what context it might be used in. The best option then is to default to safety, and allow the programmer to choose other behaviors if they need them.
- ArkyBeagle 10y agoI think it's up to the end developers to decide that the behaviors are. You/I don't know that the best option is to default to "safety" - because we lack the information necessary to make that decision. And yet again - this is UB because the original writers of the C language knew that the behavior of the hardware would be known to assembly programmers of the time.
- mikeash 10y agoYou either have to pick a default, or you have to forbid developers from writing a + operation unless they first choose an overflow behavior. I can see arguments for the latter, but it's not a common choice.