The GCC 12 release series differs from previous GCC releases in a number of ways. Some of these are a result of bug fixing, and some old behaviors have been intentionally changed to support new standards, or relaxed in standards-conforming ways to facilitate compilation or run-time performance.
Some of these changes are user visible and can cause grief when porting to GCC 12. This document is an effort to identify common issues and provide solutions. Let us know if you have suggestions for improvements!
In GCC 12, a computed goto requires a pointer type. An example which was accepted before:
void f(void)
{
goto *10;
}
is no longer accepted and you need to add a cast to it like:
void f(void)
{
goto *(void*)10;
}
Some C++ Standard Library headers have been changed to no longer include other headers that were being used internally by the library. As such, C++ programs that used standard library components without including the right headers will no longer compile.
The following headers are used less widely in libstdc++ and may need to be included explicitly when compiled with GCC 12:
<memory>
(for std::shared_ptr
, std::unique_ptr
etc.)
<iterator>
(for std::begin
, std::end
, std::size
,
std::istream_iterator
, std::istreambuf_iterator
)
<algorithm>
(for std::for_each
, std::copy
etc.)
<utility>
(for std::pair
)
<array>
(for std::array
)
<atomic>
(for std::atomic
)
<ctime>
(for std::time
, std::mktime
etc.)
<pthread.h>
(for pthread_create
, pthread_mutex_t
etc.)
Warnings have been added for use of C++ standard library features that are deprecated (or no longer present at all) in recent C++ standards. Where possible, the warning suggests a modern replacement for the deprecated feature.
The std::iterator
base class can usually be replaced by defining
the same necessary typedefs directly in your iterator class.
The std::unary_function
and std::binary_function
base classes can often be completely removed, or the typedefs for
result_type
and argument types can be defined directly in your
class.
GCC 12 now uses OPERATION
as the name of the function to
the CO_REDUCE
intrinsic for the pairwise reduction, thus
conforming to the Fortran 2018 standard. Previous versions
used OPERATOR
, which conformed to TS 18508.
Copyright (C) Free Software Foundation, Inc. Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.
These pages are maintained by the GCC team. Last modified 2022-10-26.