https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110016
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I can reproduce the failure on aarch64-linux-gnu on the trunk with `-std=c++17 -pthread -O2 -fsanitize=thread -fno-inline` so your theory about inlining is causing an issue is so incorrect.