[Bug c++/66172] -fno-threadsafe-statics suppresses guard functions but not guard variables
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66172 --- Comment #3 from Marc Singer eleventen at gmail dot com --- I've come to the same conclusion. My hope was that I could eliminate the guard and force the compiler to initialize block scoped statics at the start of execution. It looks like the standard stands in the way of this simplification.
[Bug c++/66172] -fno-threadsafe-statics suppresses guard functions but not guard variables
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66172 --- Comment #4 from Andrew Pinski pinskia at gcc dot gnu.org --- *** Bug 66173 has been marked as a duplicate of this bug. ***
[Bug c++/66172] -fno-threadsafe-statics suppresses guard functions but not guard variables
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66172 Andrew Pinski pinskia at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #2 from Andrew Pinski pinskia at gcc dot gnu.org --- You need the variable even without thread safe ones because calling the function twice means it gets initlized only once rather twice. There is no other way around this because the variable only gets initialized if the function is called.