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

rs6000: Use signed integers for __builtin_ppc_atomic_cas_local

Fixes C++ compilation errors for PowerPC atomic compare-and-swap builtins by using correct signed integer types.

This commit resolves C++ compilation failures on PowerPC targets related to the __builtin_ppc_atomic_cas_local builtin. Previously, pointer arguments were incorrectly cast to unsigned integers during overload resolution, while the builtin definitions expected signed types. This commit corrects the intermediate casting in rs6000-c.cc to use signed types, aligning with the builtin signatures and resolving the ‘invalid conversion’ errors encountered in C++.

In Details

The PowerPC __builtin_ppc_atomic_cas_local builtin, implemented in GCC's rs6000 backend, handles atomic compare-and-swap operations. Overload resolution for this builtin in rs6000-c.cc incorrectly used unsigned int for pointer arguments. This commit corrects the overload resolution handler to use signed int types, matching the expected types in rs6000-builtins.def. This fix is particularly relevant for C++ due to its stricter type conversion rules compared to C.

For Context
__builtin_ppc_atomic_cas_local
A GCC builtin function specific to PowerPC architectures that performs an atomic compare-and-swap operation on a local memory location. It atomically checks if a memory location holds a given expected value and, if so, replaces it with a new value.
Atomic operation
An operation that is guaranteed to execute indivisibly, without interruption from other threads or processes. This is crucial for concurrent programming to prevent race conditions.
Overload resolution
In C++, the process by which the compiler determines which function or operator overload to call based on the arguments provided. Builtin functions can also have overload resolution logic.
PowerPC
A RISC (Reduced Instruction Set Computer) instruction set architecture developed by Apple, IBM, and Motorola. It is used in various embedded systems and formerly in Apple Macintosh computers.
Filed Under: rs6000powerpcbuiltinc++bugfix