2 ms·
IMO, that's a job for the type system. But if you can only have one option, clearly an error is the best one. Anyway, none of those are anything nearly as dama
by marcosdumay 3y ago
IMO, that's a job for the type system. But if you can only have one option, clearly an error is the best one.
Anyway, none of those are anything nearly as damaging as C's UB. All of them are reasonable, on the literal sense that you can reason about them, anticipate what your program may do, and defend against the problem (or shrug it off and claim "it doesn't matter here"). You can do neither with by the spec C.
- uecker 3y agoI do not think C's UB is damaging. As I said, you instruct the compiler to insert a trap and then it is not unsafe. Example: https://godbolt.org/z/Kvrrx19Pa https://godbolt.org/z/Kvrrx19Pa The UB in the spec is exactly what makes safe use possible without enforcing it everywhere, which is not feasible for C.