4 ms·
> the only concrete thing that you can say about the compiler's reaction is that it will assume that whatever would trigger the UB will never happen Yeah! isn
by wyldfire 3y ago
> the only concrete thing that you can say about the compiler's reaction is that it will assume that whatever would trigger the UB will never happen
Yeah! isn't that enough? Your program is Wrong and therefore it should be fixed.
Reasoning about the wrongness is not time well spent. Just consider it a defect and mitigate it.
- sfink 3y agoI'm not sure what you're recommending here. There are many, many ways to trigger undefined behavior. The compiler won't tell you when you might be. Well, unless you're using a sanitizer like ubsan, but even then it'll only tell you about some. So I'm not sure when I should go fix my program that I don't know needs to be fixed. Yes, in theory you could internalize all of the rules and write UB-free code. While you're at it, be sure you only write code with no bugs at all. I'm not sure why everyone isn't doing that already...