C++11 compiler support shootout: Visual Studio, GCC, Clang, Intel (original) (raw)

It’s been more than half a year since my last comparison of the C++11 support across different compilers. This time I’d like to see how different compilers stack up based on the documentation for the pre-release versions of these compilers.

The next release of GCC is 4.8 and the upcoming version of Clang is 3.3. If you use Visual Studio 2012, you can install an experimental CTP update released in November 2012 to get additional C++11 features.

I’ve also thrown in v.13.0 of Intel’s C++ compiler out of curiosity, although it isn’t pre-release and there were a few features I couldn’t find information about. I didn’t find any information about the upcoming version of this compiler.

Feature VS2012 Nov CTP g++ 4.8 Clang 3.3 Intel 13.0
auto Yes Yes Yes Yes
decltype Yes Yes Yes Yes
Rvalue references and move semantics Yes Yes Yes Yes
Lambda expressions Yes Yes Yes Yes
nullptr Yes Yes Yes Yes
static_assert Yes Yes Yes Yes
Range based for loop Yes Yes Yes Yes
Trailing return type in functions Yes Yes Yes Yes
extern templates Yes Yes Yes Yes
>> for nested templates Yes Yes Yes Yes
Local and unnamed types as template arguments Yes Yes Yes Yes
Variadic macros Yes Yes Yes Yes
Variadic templates Yes Yes Yes Yes
Default template arguments in function templates Yes Yes Yes Yes
final method keyword Yes Yes Yes No
override method keyword Yes Yes Yes No
Strongly typed enums Yes Yes Yes Partial
Forward declared enums Yes Yes Yes Partial
Initializer lists Yes Yes Yes Partial
explicit type conversion operators Yes Yes Yes No
Raw string literals Yes Yes Yes No
Forwarding constructors Yes Yes Yes No
Template aliases No Yes Yes Yes
Defaulted methods No Yes Yes Yes
Deleted methods No Yes Yes Yes
Generalized attributes No Yes Yes Yes
New built-in types Partial Yes Yes Partial
Alignment support Partial Yes Yes No
Inline namespaces No Yes Yes No
sizeof on non-static data members without an instance No Yes Yes No
Changed restrictions on union members No Yes Yes No
User defined literals No Yes Yes No
Encoding support in literals No Yes Yes No
Arbitrary expressions in template deduction contexts No Yes Yes Don't know
Non-static data member initializers No Yes Yes Don't know
noexcept No Yes Yes Partial
constexpr No Yes Yes Partial
C99 compatibility Partial Partial Partial Yes
Thread local storage Partial Yes No Partial
Inheriting constructors No Yes No No
Rvalue references for *this No No Yes No

It looks like GCC is overtaking Clang as the compiler with the best C++11 support. Visual Studio has added several significant C++11 features such as variadic templates, initializer lists and raw literals.

I can’t really comment on how complete and bug-free these implementations are at a more fine grained level (other than VS2012 - I detail a lot of the bugs in the initial VS2012 release in my book, C++11 Rocks).

It’s also useful to look at the state of library support. I’m not going to get very specific as there are lots of small changes across the standard library. I’m also going to omit Intel’s library from this comparison.

I can say that the major additions to the library are mostly provided by all three implementations (as shown in the table below), although with various caveats.

Microsoft’s library implementation lacks anything that requires unimplemented language features such as constexpr (as of the initial release of VS2012). The library hasn’t been updated to use the features in the November 2012 CTP of the compiler such as initializer lists or variadic templates.

GCC’s libstdc++ lags somewhat as it doesn’t support regular expressions and low-level concurrency features. It also doesn’t implement constexpr methods in a lot of cases. std::function doesn’t have support for custom allocators, as Gilad noted in the comments below.

Clang’s libc++ is 100% complete on Mac OS, however various parts of it don’t yet work on Windows and Linux.

Feature MSVC libstdc++ libc++
Concurrency: async/future/promise/packaged_task Yes Yes Yes
Concurrency: thread and related Yes Yes Yes
Concurrency: condition variables Yes Yes Yes
Concurrency: mutexes Yes Yes Yes
Concurrency: atomic types and operations Yes Yes Yes
Concurrency: relaxed memory ordering and fences Yes No Yes
Smart pointers Yes Yes Yes
Tuples Yes Yes Yes
std::bind Yes Yes Yes
std::function Yes Yes Yes
Regular expressions Yes No Yes
Type traits Yes Partial Yes
std::forward_list Yes Yes Yes
std::array Yes Yes Yes
Hash tables Yes Yes Yes
Random number generation Yes Yes Yes
Compile time rational numbers (ratio) Yes Yes Yes
Time utilities (chrono) Yes Yes Yes
Initializer lists Yes Yes Yes
Diagnostics (system_error) Yes Yes Yes
STL refinements and new algorithms Yes Yes Yes
General purpose (move, forward, declval etc.) Yes Yes Yes
Minimal support for garbage collection Yes No No

It’s good to see that the language and library support is steadily improving. Clang and GCC are getting close to having full C++11 support. Visual Studio is also improving C++11 support, and I’m pleased that C++ compiler updates are happening between major releases. The list of supported features in Intel’s compilers is growing longer as well.

Who knows, by next year all four compilers might support all the C++11 features!


Keen on mastering C++11/14? I've written books focused on C++11/14 features. You can get a VS2013, Clang or a GCC edition.