C++11/14 compiler and library shootout
It’s been almost a year since my last comparison of C++11 support across different compilers, so I decided to take a break from working on my book about C++11/14 features in VS2013, and see how things have changed.
Once again, I’d like to see how different compilers stack up based on the documentation for the pre-release versions of these compilers. I’ve also included some of the current released versions for comparison.
Of course, now we have C++14 to think about in addition to C++11, so I’ve included C++14 in this comparison too.
The pre-release versions of the compilers are as follows: GCC 4.9, Clang 3.4 and Visual Studio Nov 2013 CTP.
First, let’s look at the C++11 language features. Clang 3.3 and above, and GCC 4.8 and later have complete support, so there was no point including them in the table.
C++11 language features support
Feature | VS Nov 2013 CTP | VS2013 | Intel 14.0 |
---|---|---|---|
auto | Yes | Yes | Yes |
decltype | Yes | Yes | Yes |
Lambda expressions | Yes | Yes | Yes |
nullptr | Yes | Yes | Yes |
static_assert | Yes | Yes | Yes |
Range based for loop | Yes | Yes | Yes |
Trailing return type in functions | Yes | Yes | Yes |
extern templates | Yes | Yes | Yes |
>> for nested templates | Yes | Yes | Yes |
Local and unnamed types as template arguments | Yes | Yes | Yes |
Variadic macros | Yes | Yes | Yes |
Variadic templates | Yes | Yes | Yes |
Default template arguments in function templates | Yes | Yes | Yes |
final method keyword | Yes | Yes | Yes |
override method keyword | Yes | Yes | Yes |
Strongly typed enums | Yes | Yes | Yes |
Forward declared enums | Yes | Yes | Yes |
Explicit type conversion operators | Yes | Yes | Yes |
Raw string literals | Yes | Yes | Yes |
Delegating constructors | Yes | Yes | Yes |
Template aliases | Yes | Yes | Yes |
Non-static data member initializers | Yes | Yes | Yes |
Deleted methods | Yes | Yes | Yes |
Initializer lists | Yes | Partial | Yes |
Rvalue references and move semantics | Yes | Partial | Yes |
Defaulted methods | Yes | Partial | Yes |
C99 compatibility | Partial | Partial | Yes |
New built-in types | Partial | Partial | Partial |
Member function ref qualifiers | Yes | No | Yes |
noexcept | Partial | No | Yes |
constexpr | Partial | No | Yes |
Alignment support | Yes | Partial | No |
Magic statics | Yes | No | Partial |
Thread local storage | Partial | Partial | No |
Generalized attributes | No | No | Yes |
Inline namespaces | No | No | Yes |
sizeof on non-static data members without an instance | Yes | No | No |
Encoding support in literals | No | No | Yes |
Arbitrary expressions in template deduction contexts | No | No | Yes |
Inheriting constructors | Yes | No | No |
Changed restrictions on union members | No | No | Partial |
User defined literals | No | No | No |
It looks like the Intel compiler is on par with the Visual Studio CTP. But Intel’s 14.0 compiler has been out for some time, while VS CTP is an alpha quality compiler, which means that Visual Studio trails behind everybody else, unfortunately.
How about C++14 support? The C++ standard is still in draft, but some compilers already have extensive support for C++14 language features:
C++14 language features support
Feature | Clang 3.4 | GCC 4.9 | VS Nov 2013 CTP | Intel 14.0 |
---|---|---|---|---|
Return type deduction for regular functions | Yes | Yes | Yes | No |
Binary literals | Yes | Yes | No | Yes |
Generic lambdas | Yes | Yes | Partial | No |
Tweaked wording for contextual conversions | Yes | Yes | No | No |
Runtime sized arrays with automatic storage duration | Yes | Yes | No | No |
Initialized lambda captures | Yes | Yes | No | No |
[[deprecated]] attribute | Yes | Yes | No | No |
Single quotation mark as digit separator | Yes | Yes | No | No |
C++ sized deallocation | Yes | Yes | No | No |
Variable templates | Yes | No | No | No |
Relaxed requirements on constexpr functions | Yes | No | No | No |
Member initializers and aggregates | Yes | No | No | No |
Avoiding/fusing memory allocations | Yes | N/A | No | No |
As far as libraries go, libstdc++, libc++ and Microsoft’s libraries all have at least partial support for all the features introduced in C++11. So instead of detailing those, I’ll focus on C++14 features. Once again, this is for the latest pre-release versions of the libraries available today:
C++14 library features support
Feature | libc++ | libstdc++ | VS Nov 2013 CTP |
---|---|---|---|
make_unique | Yes | Yes | Yes |
Improved operator functors | Yes | Yes | Yes |
Additional template aliases for transformation type traits | Yes | Yes | Yes |
Fixing constexpr member functions without const | Yes | Yes | No |
exchange() utility function | Yes | Yes | No |
Retrieving tuple elements by type | Yes | Yes | No |
std::result_of and SFINAE | Yes | Yes | No |
Improvements to integral_constant | Yes | Yes | No |
User-defined literals for standard library types | Yes | Yes | No |
More robust non-modifying sequence operations | Yes | Yes | No |
Quoted string I/O manipulator | Yes | Yes | No |
constexpr library additions: chrono | Yes | Yes | No |
constexpr library additions: containers | Yes | Yes | No |
constexpr library additions: utilities | Yes | Yes | No |
constexpr library additions: complex | Yes | No | No |
constexpr library additions: functional | Yes | No | No |
Compile-time integer sequences | Yes | Yes | No |
Shared locking | Yes | Yes | No |
Heterogeneous comparison lookup in associative containers | Yes | No | No |
Null forward iterators | Yes | No | No |
Sized deallocation | No | No | No |
Consistent metafunction aliases | No | No | No |
Discouraging rand() in C++14 | No | No | No |
Conclusion
Clang is obviously leading on the C++14 conformance front. There are also quite a few features implemented in GCC as well.
The interesting thing is that the process of building compilers to conform to the latest C++ standard has accelerated in recent years. With C++14, Clang has complete language support even before the standard has been finalized.
But it would be really great if Microsoft and Intel picked up their game, and brought their compilers’ conformance to the level of Clang and GCC.
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.