I would think that g ++ is pretty much confused about things using C ++, since the C library is messed up with the system! Any layout changes in C ++ library classes will cause incompatibility with other C ++ programs or libraries. Thus, I would not replace the C ++ system compiler or, more importantly, its standard C ++ library in general (unless, perhaps, the compiler provider claims that they have maintained binary compatibility with the version you are replacing).
To play or even use a different version of g ++, using the prefix approach works fine. All compiler-specific tools are implicitly called from g ++ using the corresponding version, and tools like ar, ld, ranblib, etc. In any case, it does not depend on the version of the compiler. Important components that use internally are the standard library (both headers and the library) and the preprocessor. When invoking the g ++ version, it determines which one is really needed.
By the way, when you want to play with C ++ 2011, you can also take a look at clang.
source share