Given enough compilers, all bugs are shallow

This post title is a poorly paraphrased version of Linus' law "given enough eyeballs, all bugs are shallow". What I want to illustrate is that using more than one compiler allows to notice more bugs.

I compiled some C++ code at work with Clang instead of GCC and it spotted the following issue with sleep() that GCC ignored:

#include <unistd.h>

int main(void)
{
        sleep(0.5);
        return 0;
}

As noticed by Clang, the argument of sleep is an unsigned int, so sleep(0.5) is converted to sleep(0). This is what happens when Pythonistas dare write some C code (Python's time.sleep() accepts a floating point number of seconds).

$ clang-3.8 -Wall -Werror test-sleep.c -o test-sleep
test-sleep.c:5:8: error: implicit conversion from 'double' to 'unsigned int' changes value from 0.5 to 0 [-Werror,-Wliteral-conversion]
        sleep(0.5);
        ~~~~~ ^~~
1 error generated.

This is not to say that Clang is better than GCC: both are great compilers. But the effort of compiling a code base with GCC and Clang is worth it because it catches more bugs.