https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107393
Bug ID: 107393
Summary: Wrong TLS model for specialized template
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: amonakov at gcc dot gnu.org
CC: amonakov at gcc dot gnu.org, asolokha at gmx dot com,
bergner at gcc dot gnu.org, iains at gcc dot gnu.org,
law at gcc dot gnu.org, marxin at gcc dot gnu.org,
segher at gcc dot gnu.org, seurer at gcc dot gnu.org,
unassigned at gcc dot gnu.org
Blocks: 107353
Target Milestone: ---
+++ This bug was initially created as a clone of Bug #107353 +++
template<class T>
struct S {
static __thread int i;
};
template<class T>
__thread int S<T>::i;
extern template
__thread int S<void>::i;
int &vi()
{
return S<void>::i;
}
int &ci()
{
return S<char>::i;
}
Current trunk ICEs due to a new verification in ipa-visibility, before that gcc
-O2 used to emit:
_Z2viv:
movq %fs:0, %rax
addq $_ZN1SIvE1iE@tpoff, %rax
ret
_Z2civ:
movq %fs:0, %rax
addq $_ZN1SIcE1iE@tpoff, %rax
ret
_ZN1SIcE1iE:
.zero 4
which incorrectly uses local-exec model to retrieve S<void>::i, which is extern
(and thus could reside in a shared library at link time, not the executable
being linked).
Clang correctly uses initial-exec for S<void>::i and local-exec for S<char>::i.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107353
[Bug 107353] [13 regression] Numerous ICEs after r13-3416-g1d561e1851c466