4 ms·
Tbh, I just really hate the term "undefined behavior". It really feels like laziness in terms of what the possible damage might entail.
by NoTeslaThrow 1y ago
Tbh, I just really hate the term "undefined behavior". It really feels like laziness in terms of what the possible damage might entail.
- arlort 1y agoIt is a term of art in compilers/language design though, isn't it? If you break an invariant the compiler is relying on for optimization then you can't say for sure what the effect after all optimisation passes or in future versions of the compiler will be. It's just "undefined"
- imtringued 1y agoYeah I personally think the problem isn't undefined behavior itself, but the C development culture where undefined behavior is sprinkled all over the language to the point where it has become unavoidable plus the inevitable assignment of blame onto C developers, because everyone knows there is enough time in the day for fuzzing your entire code base.
- Dylan16807 1y agoIn a situation like this, causing UB is basically saying you deliberately corrupted your memory. How are you supposed to be specific about what the possible damage might entail for corrupted memory? If you have a function with an "if" or a "while" or a "switch" in it, and you break the variable being evaluated, you might cause the program to skip over the choices and run whatever happens to be next in memory. What's the non-lazy listing of possible outcomes at that point?