As with every major GCC release, GCC 12.1, which will be released this week, brings many new features, improvements, and bug fixes. In a recent blog post, Red Hat’s Marek Polacek outlines some of the C++ language improvements that have been made in this major GNU Compiler Collection update.
Polacek notes that a total of several C++23 proposals are implemented in GCC 12. The default dialect in GCC 12 is -std=gnu++17; to enable C++23 features, you need to use the -std=c++23 or -std=gnu++23 command-line option, the latter of which allows GNU extensions. It is worth noting, however, that the C++20 and C++23 features are still experimental in GCC 12.
According to introduction, GCC 12 implements C++23’s if consteval, auto(x), non-literal in constexpr functions variables, multidimensional subscript operators, elifdef and elifndef preprocessing directives, extended init-statement, folding of trivial functions, and more. GCC 12 also introduces a variety of new and improved compiler warnings, static parser improvements, and more features.
For next year’s GCC 13, the development team is aiming to complete support for C++23. More details can be found on the blog.