https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128437
Bug ID: 128437
Summary: ICE: output_operand: '%&' used without any local
dynamic TLS references on x86_64 with -O2 -fPIC
-fvisibility=hidden
Product: gcc
Version: 16.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: george.cox at gmail dot com
Target Milestone: ---
$ g++-16 -fPIC -fvisibility=hidden -O2 -c t.cpp
during RTL pass: final
t.cpp: In function 'void g()':
t.cpp:28:1: internal compiler error: output_operand: '%&' used without any
local dynamic TLS references
t.cpp:
void f();
void *p;
struct { void *slot; } *entries;
long capacity;
void erase() {
if (capacity)
return;
for (int i = 0; entries[i].slot; ++i)
if (!entries)
entries = {};
}
thread_local int current, x, y;
void released(void *) {
if (current)
erase();
}
struct Ref {
int v;
~Ref() { released(&v); }
};
void replace(int, Ref) {
if (p)
f();
}
void g() {
replace(x, {});
replace(y, {});
}
Fails: Debian 16.2.0-4 and Debian 14.4.0-3, x86_64-linux-gnu.
No ICE with -O1, without -fPIC, without -fvisibility=hidden, or with
-mtls-dialect=gnu2.
Same message as PR110606 (powerpc64le).
The test case is about the same line count as the source file, so the line
number in the error (t.cpp:28:1) stays correct if you save it as t.cpp exactly
as shown.
