Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which 4.x version of gcc should one use?

Tags:

c

gcc

The product-group I work for is currently using gcc 3.4.6 (we know it is ancient) for a large low-level c-code base, and want to upgrade to a later version. We have seen performance benefits testing different versions of gcc 4.x on all hardware platforms we tested it on. We are however very scared of c-compiler bugs (for a good reason historically), and wonder if anyone has insight to which version we should upgrade to.

Are people using 4.3.2 for large code-bases and feel that it works fine?

like image 573
Olof Avatar asked Aug 28 '08 14:08

Olof


People also ask

Should I use latest GCC?

In general, it is a good idea to use the latest g++ compiler. However, in a few occasions I have had problems with the libraries that I use. For example, the version 4.5 of g++ broke the version of boost::xpressive that I was using. Or better said, it revealed something broken in the library.

Can I have multiple versions of GCC?

With GCC compilers installed, we can now proceed to install multiple versions of G++ compilers. Alternatively, you can install both GCC and G++ compilers with a single command, as shown below.


2 Answers

The best quality control for gcc is the linux kernel. GCC is the compiler of choice for basically all major open source C/C++ programs. A released GCC, especially one like 4.3.X, which is in major linux distros, should be pretty good.

GCC 4.3 also has better support for optimizations on newer cpus.

like image 108
nimish Avatar answered Sep 19 '22 13:09

nimish


When I migrated a project from GCC 3 to GCC 4 I ran several tests to ensure that behavior was the same before and after. Can you just run a run a set of (hopefully automated) tests to confirm the correct behavior? After all, you want the "correct" behavior, not necessarily the GCC 3 behavior.

like image 44
dmo Avatar answered Sep 19 '22 13:09

dmo