Which is the best C++ compiler? [closed]

2020-05-23 08:28发布

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?

9条回答
手持菜刀,她持情操
2楼-- · 2020-05-23 09:00

First of all which platform you are using usually dictates which compilers to use.

Secondly, your question on robustness and performance. I am not sure what you mean by robustness. but if you mean correctness of the compiled binaries, I'd have to say as long as you are using a stable version of any of the compilers you mentioned you are not going to run into "robustness" problems. These compilers are all very mature and have been used in countless real life projects. So I would not worry about robustness at all.

Regarding performance, That is a tough one to answer because each compiler has different optimisation techniques which could theoretically yield different performance. I hope there is someone more knowledgable than me that can tell you about this.

In reality, given that the compilers that you mentioned are all high quality and mature compilers, the questions that you should be asking, are not which compiler is more robust, but:

  • Which is the compiler that supports my target platform
  • Which is the compiler that works well with my development environment and tools?
  • Which compiler is my development team and integrators most familiar with.

The question of optimisation techniques is an open question however, and it is a non trivial question at that. I hope some could shed some light on it.

查看更多
等我变得足够好
3楼-- · 2020-05-23 09:00

The point of an optimizing compiler is that it should generate an optimized program that is functionally equivalent to the original. Functional equivalent has to do with observable effects, of course; the state would naturally not be the same. Any compiler that can generate an incorrect translation is bad, in my opinion, although I suppose that you could relax certain issues in different situations. One advantage of a mainstream compiler is that bugs are fixed faster.

As for performance, compilers generally do two types of optimizations: platform-independent optimizations (at the source level/syntax tree/intermediate representation), and platform-specific ones.

I would guess that the best platform-independent optimizations are probably in various academic modifications of existing compilers (but probably a different optimization and each). These optimizations are eventually recognized and eventually trickle into the mainstream.

As for platform-specific optimizations, I think that companies making these platforms often have the best optimizations (e.g., the internal Intel compilers), but they are not yet integrated into general-availability compilers, and eventually trickle down as well.

查看更多
在下西门庆
4楼-- · 2020-05-23 09:08

In addition to Bastien Léonard answer: There is one more multi-platform C++ compiler — Comeau. It is the most standards-conformant C++ compiler. Last version has C++0x core language support.

查看更多
登录 后发表回答