[v3,2/2] gcc-17: s390: ABI change for nullptr_t return values
Checks
Commit Message
From: Stefan Schulze Frielinghaus <stefansf@gcc.gnu.org>
---
htdocs/gcc-17/changes.html | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
@@ -250,6 +250,43 @@ for general information.</p>
<li>Support for <code>-m31</code> was removed and as a consequence
<code>-mesa</code> support.
</li>
+
+ <li id="s390_return_nullptr_type">
+ Starting with GCC 4.6 (which introduced initial C++11 and
+ <code>std::nullptr_t</code> support), arguments of type
+ <code>nullptr_t</code>, <code>std::nullptr_t</code>, and
+ <code>decltype(nullptr)</code> are passed in registers. However, return
+ values were erroneously returned in memory, violating the psABI. GCC 17
+ fixes this so that <code>nullptr_t</code> and related types are returned in
+ a register (<code>r2</code>), matching argument passing and the psABI.
+ Functions returning <code>nullptr_t</code> compiled with GCC 17 are
+ ABI-incompatible with binaries compiled by older GCC versions. For
+ example, if the translation unit of <code>foo()</code> is compiled with a
+ GCC version prior to 17
+
+<pre><code>nullptr_t foo (int x)
+{
+ return nullptr;
+}</code></pre>
+
+ and the translation unit of <code>main()</code> with GCC 17
+
+<pre><code>extern nullptr_t foo (int);
+int main (void)
+{
+ foo (0);
+}</code></pre>
+
+ then running the program results in a segfault because <code>foo()</code>
+ expects in <code>r2</code> the hidden argument where to store the return
+ value, whereas <code>main()</code> passes the first named argument in
+ <code>r2</code> (which is zero), leading to a segfault once written to.
+
+ <p>Affected code must be recompiled with GCC 17 to restore psABI
+ compatibility. Compiling with <code>-Wpsabi</code> emits a diagnostic for
+ function definitions and call sites affected by this change; at most one
+ diagnostic is emitted per function.</p>
+ </li>
</ul>
<!-- <h3 id="riscv">RISC-V</h3> -->