https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126230
--- Comment #8 from Tomasz KamiĆski <tkaminsk at gcc dot gnu.org> --- > Now, this is guaranteed to terminate before P0528 with GCC12 (max. 2 > iterations) It is guaranteed to work due how libstdc++ implemented them, however not strictly by standard, the C++17 version (https://timsong-cpp.github.io/cppwp/n4659/atomics.types.operations#18) says that the expected is replaced by the value (that does not include padding bits): > If and only if the comparison is false then, after the atomic operation, the > contents of the memory in expected are replaced by the value read from the > memory pointed to by this during the atomic comparison.
