On 07/05/20 11:08 +0200, Jakub Jelinek wrote:
Hi!
This is my humble attempt to document the C++ ABI changes.
Or do you have something better?
Not sure e.g. how C++ calls the TREE_ADDRESSABLE types which are
passed/returned by invisible reference, perhaps it would be nice
to make it clear that those aren't affected.
As the release tarballs contain a copy of changes.html, I'm afraid
we need to resolve this before I can roll the tarballs.
--- htdocs/gcc-10/changes.html 2020-05-07 10:44:17.391465227 +0200
+++ htdocs/gcc-10/changes.html 2020-05-07 11:02:50.580691123 +0200
@@ -31,6 +31,27 @@ a work-in-progress.</p>
<h2>Caveats</h2>
<ul>
<li>
+ <a name="empty_base">The ABI</a>
+ of passing and returning certain C++ classes by value changed
+ on several targets in GCC 10, including AArch64, ARM, PowerPC ELFv2,
+ S/390 and Itanium. In <code>-std=c++17</code> and <code>-std=c++20</code>
+ modes for classes with empty bases which otherwise contain only a single
+ element or are handled as homogeneous aggregates in
+ <code>-std=c++14</code> and earlier modes the existence of the empty
+ bases resulted in those classes not to be considered as having a single
+ element or be homogeneous aggregate and so could be passed differently,
+ making <code>-std=c++17</code> and <code>-std=c++14</code> compiled code
+ ABI incompatible. This has been corrected and the empty bases are
+ ignored in those ABI decisions, so <code>-std=c++14</code> and
+ <code>-std=c++17</code> compiled codes are now again ABI compatible.
+ Example: <code>struct empty {}; struct S : public empty { float f;
}</code>.
+ Similarly, in classes containing non-static data members with empty
+ class types and with C++20 <code>[[no_unique_address]]</code> attribute
+ those members weren't ignored in the ABI argument passing decisions
+ as they should be. Both of these ABI changes are now diagnosed with
+ <code>-Wpsabi</code>.
+ </li>
+ <li>
The deprecated Profile Mode and <code>array_allocator</code> extensions
have been removed from libstdc++.
</li>
Here's what I've committed after discussion on IRC, combining Jakub's
text with what I had.
commit f1d2be6c9fcc52d676266e7ede123953d150aaf3
Author: Jonathan Wakely <jwak...@redhat.com>
Date: Thu May 7 11:24:04 2020 +0100
Document C++17 ABI changes in GCC 10
diff --git a/htdocs/gcc-10/changes.html b/htdocs/gcc-10/changes.html
index f5b70eb4..52fd6e6a 100644
--- a/htdocs/gcc-10/changes.html
+++ b/htdocs/gcc-10/changes.html
@@ -30,6 +30,12 @@ a work-in-progress.</p>
<!-- .................................................................. -->
<h2>Caveats</h2>
<ul>
+ <li>
+ An ABI incompatibility between C++14 and C++17 has been fixed. On some
+ targets a class with a zero-sized subobject would be passed incorrectly
+ when compiled as C++17 or C++20.
+ See the <a href="#empty_base">C++ notes below</a> for more details.
+ </li>
<li>
The deprecated Profile Mode and <code>array_allocator</code> extensions
have been removed from libstdc++.
@@ -409,6 +415,39 @@ int get_na??ve_pi() {
The attribute <code>deprecated</code> can now be used on
<code>namespace</code>s too.
</li>
+ <li>
+ <a name="empty_base">The ABI</a>
+ of passing and returning certain C++ classes by value changed
+ on several targets in GCC 10, including
+ <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94383">AArch64</a>,
+ <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94711">ARM</a>,
+ <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94383">PowerPC ELFv2</a>,
+ <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94704">S/390</a>
+ and
+ <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94706">Itanium</a>.
+ These changes affect classes with a zero-sized
+ subobject (an empty base class, or data member with the
+ <code>[[no_unique_address]]</code> attribute) where all other non-static
+ data members have the same type (this is called a "homogeneous aggregate"
+ in some ABI specifications, or if there is only one such member,
+ a "single element").
+ In <code>-std=c++17</code> and <code>-std=c++20</code> modes, classes with
+ an empty base class were not considered to have a single element or
+ to be a homogeneous aggregate, and so could be passed differently
+ (in the wrong registers or at the wrong stack address). This could make
+ code compiled with <code>-std=c++17</code> and <code>-std=c++14</code>
+ ABI incompatible. This has been corrected and the empty bases are
+ ignored in those ABI decisions, so functions compiled with
+ <code>-std=c++14</code> and <code>-std=c++17</code> are now ABI compatible
+ again.
+ Example:
+ <code>struct empty {}; struct S : empty { float f; }; void f(S);</code>.
+ Similarly, in classes containing non-static data members with empty
+ class types using the C++20 <code>[[no_unique_address]]</code> attribute,
+ those members weren't ignored in the ABI argument passing decisions
+ as they should be. Both of these ABI changes are now diagnosed with
+ <code>-Wpsabi</code>.
+ </li>
</ul>
<h4 id="libstdcxx">Runtime Library (libstdc++)</h4>