https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60673
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #2) > This seems to be fixed in GCC 5 onwards (and recent Clang versions). It was not fixed until GCC 7.5, 8.4 and 9+. Here is a reduced testcase which shows it was not fixed until then: extern "C" void abort(void); struct tt { int *tt1 = new int{1}; int bucket_count() const {return *tt1;} }; struct A{ static thread_local tt s; int f() { return this->s.bucket_count(); } int g() { return A::s.bucket_count(); } int h() { return s.bucket_count(); } }; thread_local tt A::s; int main() { if (A{}.f() != 1) abort(); return 0; }