https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121148
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |danglin at gcc dot gnu.org --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- If I understand correctly, the hppa code in libstdc++-v3/config/cpu/hppa/atomicity.h is only using assembly for a spinlock, then the actual arithmetic happens in plain C++ code: _Atomic_word result; int tmp; volatile int& lock = _Atomicity_lock<0>::_S_atomicity_lock; __asm__ __volatile__ (_PA_LDCW_INSN " 0(%1),%0\n\t" "cmpib,<>,n 0,%0,.+20\n\t" "ldw,ma 0(%1),%0\n\t" "cmpib,<> 0,%0,.-12\n\t" "nop\n\t" "b,n .-12" : "=&r" (tmp) : "r" (&lock) : "memory"); result = *__mem; *__mem = result + __val; __asm__ __volatile__ ("stw,ma %1,0(%0)" : : "r" (&lock), "r" (tmp) : "memory"); return result; So this will need to use an unsigned type, as shown in comment 0.