The C++ Hightlights and more of GCC 6.1
published at 28.04.2016 21:58 by Jens Weller
Save to Instapaper Pocket
In this week GCC 6.1 was released, a new major version of GCC. This new version brings again many new features for C++ to the GNU Compiler Collection. A short overview on these.
Soon after the release, a lot of the attention went to an interesting point listed quite soon inside the release notes:
Value range propagation now assumes that the
this
pointer of C++ member functions is non-null. This eliminates common null pointer checks but also breaks some non-conforming code-bases (such as Qt-5, Chromium, KDevelop). As a temporary work-around-fno-delete-null-pointer-checks
can be used. Wrong code can be identified by using-fsanitize=undefined
.
Especially, as with Qt5 and Chromium two heavily used code bases are affected, also KDevelop is a well known IDE. Also KDE builds upon Qt5, so this seems like a really important point. The standard guarantees that this is non-null, so this change is a good one. Also, this thread on the qt mailing list shows, that Qt already has checked its code base, and fixed things where necessary. I expect Chromium and other affected codebases have done the same. So, no big deal actually.
This second paragraph of the release notes also hints at an improved UB Sanitizer and improvements in LTO, aliasing,
Also C++14 is now the default mode for GCC, which is great, but also most of our projects probably already supply the compiler with the standard to use, but nice to see this move to the newest standard.
So, lets look at the interesting stuff.
C family (aka also interesting for C++)
This version brings OpenMP 4.5 and OpenACC 2.0. Enums can now have attributes, allowing to deprecate an enum member. A big leap forward is the handling of error messages. GCC now handles errors as ranges, not as points, so it tells you where an error starts and ends, and initial support for errors in strings, e.g. printf formatting. Diagnostics now contain hints how to fix a certain error, also some spell checking is done, so if you mistype a member, a suggestion will hint at the member you meant. Also GCC will detect version control markers left in files and error on them, instead of turning them into weird error messages.
C++
With C++14 being default, one can expect to have full C++14 support with this compiler. While the last version already brought this for the compiler, the standard library for C++14 was still experimental.
Previously already known was, that this version would be the first compiler to bring concepts. GCC 6.1 is the first, and currently only compiler that supports concepts through -fconcepts.
This version also brings more C++17 support:
- C++17 language
- fold expressions, u8 literals, extended static_assert & nested namespaces
- C++17 library
- uncaught_exception function
- try_emplace & insert_or_assign for unique key maps
- size, empty and data as non member functions
- at least size should also work with arrays
- invoke
- shared_mutex
- void_t & bool_constant
- experimental <filesystem>
- experimental support for Library Fundamentals TS
And: Transactional Memory, enabled with -fgnu-tm.
Join the Meeting C++ patreon community!
This and other posts on Meeting C++ are enabled by my supporters on patreon!