https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113627
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- My gut feeling is there is some variable is not being treated as atomic. That is there is a race condition somewhere. I am not saying you example code has a race condition in it but rather that seems like the cause of the bug.