The C++ highlights and more of GCC 5.1
published at 23.04.2015 20:56 by Jens Weller
Save to Instapaper Pocket
Just recently, GCC 5.0 has been released as GCC5.1, the not only the newest version of GCC, but also bumping up the version number from 4 to 5. This release is a major milestone for GCC, but also for C++, as it brings full C++14 support, but yet not C++11(std=c++11) as the new default. So the C++ world has now two fully C++14 compatible compilers: Clang and GCC.
C++ Highlights
As already mentioned, this release brings full C++14 support to the compiler, and experimental C++14 support to the standard library. Also, with the standard library, there comes a very important change: this release comes with a new ABI. Which is also the default, so linking code from 4.x and the new 5.x branch will have surprises, when the old ABI is not explicitly used. To use the old ABI you must define _GLIBCXX_USE_CXX11_ABI
to 0. Also with this changes the implementation of std::string (no more copy on write) and std::list (lists have to know their size [O(1) lookup time)]).
On the C++14 feature list variable templates are now supported, also the extended constexpr functions have found their way into GCC. The sized de/allocation and a few of the other missing C++14 features have also been added. Removed was the support for variable lenght arrays, as this was also removed from the C++14 draft (but GNU VLAs are still supported).
Yet this release also contains new C++11 features for the library. As a language it is supported for some time now, but a few things are new to the library:
std::deque
andstd::vector<bool>
meet the allocator-aware container requirements;- movable and swappable iostream classes;
- support for
std::align
andstd::aligned_union
; - type traits
std::is_trivially_copyable
,std::is_trivially_constructible
,std::is_trivially_assignable
etc.; - I/O manipulators
std::put_time
,std::get_time
,std::hexfloat
andstd::defaultfloat
; - generic locale-aware
std::isblank
; - locale facets for Unicode conversion;
- atomic operations for
std::shared_ptr
; std::notify_all_at_thread_exit()
and functions for making futures ready at thread exit.
Also this version of GCC brings experimental support for the library fundamental TS, support for any, apply, sample, search, not_fn has been added to std::experimental, also type traits are available in an (experimental) template variable version.
Also note, that a few C++0x type traits (those not supported by C++11) have been deprecated, and will be removed in a future version, this will of course not affect any C++11 type trait.
But wait, there is more:
New Parallelism in GCC 5.x
2 major additions to this release for C++ devs are the new ways to use parallelism in your programs. With this release OpenMP 4.0 and Cilk+ is supported!
The support for Intel Cilk+ is new to GCC, with this release, CilkPlus is fully supported in GCC! This means you can now start using cilk_for, cilk_spawn and cilk_sync in your programs! For details see the Cilk+ on GCC webpage.
While GCC has supported OpenMP for quite a long time, this new version brings also the newest evolution of OpenMP: 4.0. For details on OpenMP see the published OpenMP 4.0 Examples.
Also interesting:
GCC 5 includes a preliminary implementation of the OpenACC 2.0a specification. OpenACC is intended for programming accelerator devices such as GPUs. See the OpenACC wiki page for more information.
C Highlights
As C is also a little bit part of C++, a short overview on the changes for C. Important to know is that also the default to for C changes to std=c11. Interesting is the new __has_attribute macro, which also exists in a C++ version: __has_cpp_attribute. Also for includes now __has_include and _has_include_next have been added. There are a few new build options and warnings for C too.
GCC improvements
There is a new command-line argument -freport_bug, which causes "GCC automatically generates a developer-friendly reproducer whenever an internal compiler error is encountered".
Join the Meeting C++ patreon community!
This and other posts on Meeting C++ are enabled by my supporters on patreon!