[Bug c++/83730] Unnecessary generation of guard variables with -fno-threadsafe-statics
klaus.doldinger64 at googlemail dot com
gcc-bugzilla@gcc.gnu.org
Mon Jan 8 12:09:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83730
--- Comment #5 from Wilhelm M <klaus.doldinger64 at googlemail dot com> ---
Only for completeness: if you write the following, no guards are produced:
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();
}
So the c++14 an c++17 variants produce the same guards if
default-initialization is used. But produce no guards if value-initialization
ist used or the defaulted ctor is removed. Thats strange ...
More information about the Gcc-bugs
mailing list