4 ms·
What a useless and jaded assumption that code written in the past is bad.
by flqn 4y ago
What a useless and jaded assumption that code written in the past is bad.
- jolux 4y agoThe assumption being made here is "any useful C program relies on undefined behavior" which is pretty much true.
- ErikCorry 4y agoYes and I'm sure it's doubly true of code that was written before the C standards were written.
- pantalaimon 4y agoThat sounds like a strong take - to you have examples? Compiling with -Wall -Werror is pretty much standard those days.
- morelisp 4y ago-Wall -Werror is mostly designed to catch dangerous but totally well-defined idioms, not UB. It doesn't warn on every signed arithmetic operation or unchecked array access, for example.
- jolux 4y agoSee "useful" — it may not be not quite as strong as you're thinking. It may be possible to write a minimal C program without UB, but I'm thinking of larger programs, more than a few hundred lines. Common UB includes: array access out of bounds, dereferencing a null pointer, use after free, use of uninitialized variables. -Wall -Werror can catch some instances of some types of UB, and runtime libraries like UBSan can catch more. But they're not exhaustive.
- ErikCorry 4y agoI certainly didn't say it was bad. Just that it went outside the boundaries of a standard that was written 25 years later.