That would not work. Since the test may not cause any problems. While the compiler might find more optimzation opportuinities in the real program. (Just as the begining of the function did not have problem, but the for loop had.)
2. Users report that it started crashing sometimes in version V.
3. After lots of debugging, you discover an input that reliably crashes your program after 30 minutes.
4. A bit later, you discover that your compiler started compiling function f so that it no longer works with unaligned data/buffers of exactly 8 bytes/whatever.
5. At the start of main, you add a dummy call to f with data that reliably crashes if your compiler decides to do that optimization again.
6. The program has become worse: it now always crashes, independent of its input, but you don't have to wait 30 minutes before finding out. That makes it way less likely that you ship a binary again that has the problem. It also makes it easier to tweak source code/compiler flags/whatever until the problem disappears.
Is that perfect? Absolutely not, it is more something of last resort, but depending on the costs of crashing versus those of sometimes crashing half-way through a run, it can be an improvement.
(this technique also can be used when your code hits compiler bugs)
Well, it is blaming someone who does not know how to use its tools.
If I had writen a blog post aboug how I spent one day trying to fix a leak and then discovered that I always had to call free() after malloc(); would it still be victim blaming than blame me for not knowing the basic of C?
> The alignment bug here is such an example.
It is not since it allows vectorisation. The error was to assume that what one writes in C translates directly to assembly.