I am well aware, that there will probably not be "the one most difficult to find error in c++", but I am still interested in what other people can think of / may have already encountered.
The idea for this question arose during a discussion with a friend. We agreed, that it must be rather simple to sabotage a cpp project by delierately including errors in the source code that you submit... But the best thing we could think of was to use uninitialized variables (leading to random segmentation faults at runtime). I am sure there are better ways...?!
Wanted characteristics of the faulty code:
- must look like valid code on first sight
- must not stop the code from compiling (too obvious)
- if possible the error should look like it might just have been a mistake (should it ever be found)
- the error must be grave enough to stop the software from shipping (e.g. random seg faults, logical malfunction of the code etc.)
Still, while it must be noticeable, it should not be obvious right after the submition of the code... Well, you get the idea.
Don't worry, our considerations are purely theoretical (we do not plan to sabotage any project). We simply considered this to be a nice enough thought experiment to share with others :-)
In short:
What is the most subtle way to sabotage sourcecode that might go unnoticed in a differential commit (like git) but will ultimately prevent a release of the software?