https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102496
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:701075864ac4d1c6cec936d10f9cfc2aeb8c1699 commit r12-4032-g701075864ac4d1c6cec936d10f9cfc2aeb8c1699 Author: Jakub Jelinek <ja...@redhat.com> Date: Fri Oct 1 10:30:16 2021 +0200 c++: Fix handling of __thread/thread_local extern vars declared at function scope [PR102496] The introduction of push_local_extern_decl_alias in r11-3699-g4e62aca0e0520e4ed2532f2d8153581190621c1a broke tls vars, while the decl they are created for has the tls model set properly, nothing sets it for the alias that is actually used, so accesses to it are done as if they were normal variables. This is then diagnosed at link time if the definition of the extern vars is __thread/thread_local. 2021-10-01 Jakub Jelinek <ja...@redhat.com> PR c++/102496 * name-lookup.c (push_local_extern_decl_alias): Return early even for tls vars with non-dependent type when processing_template_decl. For CP_DECL_THREAD_LOCAL_P vars call set_decl_tls_model on alias. * g++.dg/tls/pr102496-1.C: New test. * g++.dg/tls/pr102496-2.C: New test.