4 ms·
They are from actual software but that doesn't make them less trivial – assignment instead of equality, unbalanced parentheses which invoke the comma operator,
by bluetomcat 10y ago
They are from actual software but that doesn't make them less trivial – assignment instead of equality, unbalanced parentheses which invoke the comma operator, mistyped names of variables in repetitive expressions which do not stand out due to the idiotic indentation, not knowing that arrays decay to pointers when passed to functions.
Those things can indeed cause a lot of harm but they are far less frequent in codebases not written by monkeys, compared to issues like undefined behaviour due to misunderstanding the language semantics, integer overflow, not checking whether a call has returned an error, etc.
- the_af 10y agoAgain, I don't understand the argument. Actual software is full of "trivial" bugs. That they are trivial doesn't seem to stop programmers from writing them! I don't know about you, but in my experience I find plenty of inexperienced programmers (and oddly, even some supposedly experienced ones) who write poorly indented software with repetitive expressions. Sometimes the verbosity of the programming language -- or the lack of a good static checker -- even encourages this. Saying "don't write code with trivial errors" is almost like saying "don't write bugs". We all know how well that works. We must deal with the fact trivial bugs occur, and that they occur often; anything else is like hiding your head in the sand. This is an argument in favor of static code analyzers.
- bluetomcat 10y agoMy argument does not advocate the neglection of these issues in any way. It's simply that such bugs are the low-hanging fruit and are far less frequent than much subtler issues which can have the same adverse effect.