https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83730
Bug ID: 83730 Summary: Unnecessary generation of guard variables with -fno-threadsafe-statics Product: gcc Version: 7.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: klaus.doldinger64 at googlemail dot com Target Milestone: --- Compiling the following example using -fno-threadsafe-statics and -Os still generates the guard-variables for the member mTop. This is unnecessary and occupies 8 Bytes on an avr target. struct A { A() = default; // if commented out, no guards are allocated void foo() {} }; template<typename T> struct B { static void foo() { mTop.foo(); } inline static T mTop; }; int main() { B<A>::foo(); }