GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/s390 Breaking Change

s390 now returns nullptr_t in a register, fixing an ABI mismatch

GCC on s390 returned nullptr_t in memory against the psABI. It now uses a register, which breaks binary compatibility with older GCC.

Since GCC 4.6, s390 passed nullptr_t arguments in registers but returned nullptr_t values through memory, which contradicts the psABI. The fix teaches s390_return_in_memory to treat NULLPTR_TYPE like other register-passed scalars, as s390_function_arg_integer already does. A memory return adds a hidden first argument, so this change shifts every named argument of affected functions by one GPR. Code built with GCC 17 that calls a nullptr_t-returning function compiled with an older GCC (or the reverse) can therefore crash. A new psABI note warns about the change, and it skips functions that have no external linkage and whose address is never taken.

In Details

The change is in the s390 backend's TARGET_RETURN_IN_MEMORY hook, s390_return_in_memory in s390.cc. It must agree with s390_function_arg_integer, which already handled NULLPTR_TYPE. The psABI note uses cgraph's externally_visible flag instead of TREE_PUBLIC, because LTO partitioning makes static functions public. A return-slot change alters the hidden-pointer register assignment, so it affects argument layout, not just the return value.

For Context
psABI
The processor-specific ABI. It fixes calling conventions, register use, and type layout for one architecture, so separately compiled code can interoperate.
nullptr_t
The C++11 type of the nullptr literal (std::nullptr_t, decltype(nullptr)). It is pointer-sized, and the s390 psABI treats it as a scalar that goes in a register.
s390_return_in_memory
The s390 backend's implementation of the target hook that decides whether a function's return value goes through a caller-supplied memory slot or in registers.
hidden argument
An implicit first parameter, normally in the first GPR, that holds the address of the caller's return-value buffer when a value is returned in memory. It shifts all named arguments to the following registers.
externally_visible
A cgraph node flag marking a symbol as reachable from outside the compilation unit. The diagnostic uses it instead of TREE_PUBLIC, because LTO partitioning can make static functions public.
LTO partitioning
Link-time optimization splits the whole program into partitions that are compiled separately. Doing so can promote static symbols to public ones so partitions can reference them.
Filed Under: s390abic++nullptr_tcalling-convention