Search code examples
c++mission-critical

Which is the best C++ compiler?


Can a C++ compiler produce a not so good binary? You can think here of the output's robustness and performance. Is there such a thing as the "best" C++ compiler to use? If not, what are the strong points, and of course, the not-so-strong (known Bugs and Issues) points, of the well-known compilers (g++, Intel C++ Compiler, Visual C++, etc.).

Are there documented cases when a compiler produced incorrect output which resulted in a failure of mission-critical software?


Solution

  • G++ seems to be the most popular. It's free, portable and quite good. The Windows port (MinGW) was really dated the last time I used it (maybe one year ago).

    The Intel C++ compiler is considered as the one which generates the fastest code (however it's known that it generates bad SIMD code for AMD processors). You can use it freely on GNU/Linux under quite restrictive conditions.
    I've used it for some time and I liked the fact that it emits clever warnings which others don't.

    VC++ is often regarded as the best C++ IDE, and from what I hear the compiler is quite good too. It's free (as in free beer), and only available on Windows of course.
    If you are interested in Windows programming I would suggest this compiler, because it's always up-to-date and provides more advanced features for this purpose.

    I would suggest VC++ on Windows, G++ for other OSes. Try the free version of I++ yourself, to see if it's worth the money.


    Are there documented cases when a compiler produced incorrect output which resulted in a failure of mission-critical software?

    Yes, probably, but I'd say that most of the time it's probably the programmer's fault. For example, if someone doesn't know how floating-point arithmetic works, it's easy to write unreliable code. A good programmer must also know what is guaranteed to work by the C++ standard and what isn't. The programmer should also know what are the limits of the compiler, e.g. how well it implements the standard and how aggressively it optimizes.