https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115802
--- Comment #3 from Ivan Bodrov <securesneakers at gmail dot com> --- Yes, but "wait" operation is not supposed to touch anything. The example shows typical usage of condition variable, except "real" code usually accesses data through some pointer, not as a static variable. Or links dynamically to mutex/condvar code. Once everything is linked statically and LTO is enabled, this transformation breaks it. Not a common case, but the code seems correct to me.