https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117813

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
E.g.
int baz ();
void qux (int *);
template <int N>
struct S {
#define P qux (v);
#define Q P P P P P P P P P P
#define R Q Q Q Q Q Q Q Q Q Q
  constexpr S () { if consteval { } else { int v[baz ()]; R R R R R R R R } }
};
//extern template struct S<0>;
constexpr S<0> a;
S<0> b;
S<0> c;
S<0> d;
compiled with g++ 12 -Os -std=c++23 -fno-ipa-cp -fno-ipa-sra
only exported _ZN1SILi0EEC4Ev.
With -Os -std=c++23 -fno-ipa-cp -fno-ipa-sra
only exported _ZN1SILi0EEC1Ev.
Though, admittedly with
template struct S<0>; at the end it also exports
_ZN1SILi0EEC2Ev and _ZN1SILi0EEC1Ev.
Now, if one in some other TU uses the same with extern template struct S<0>;
seems C1 is called in all cases.  So maybe just arranging for the extern
template cases
that one never references C4 might be good enough.

Reply via email to