glibc/elf/tst-unique4lib.cc
H.J. Lu dbc9a40007 tst-unique[34].cc: Use explicit instantiation declaration/definition
Use explicit instantiation declaration and definition to silence Clang
error:

tst-unique3.cc:6:18: error: instantiation of variable 'S<char>::i' required here, but no definition is available [-Werror,-Wundefined-var-template]
    6 | int t = S<char>::i;
      |                  ^
./tst-unique3.h:5:14: note: forward declaration of template entity is here
    5 |   static int i;
      |              ^
tst-unique3.cc:6:18: note: add an explicit instantiation declaration to suppress this warning if 'S<char>::i' is explicitly instantiated in another translation unit
    6 | int t = S<char>::i;
      |                  ^

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2025-01-03 04:54:44 +08:00

28 lines
775 B
C++

// BZ 12511
#include "tst-unique4.h"
template<> int S<1>::i = 1;
template<> int S<2>::i = 2;
template<> int S<3>::i = 3;
template<> int S<4>::i = 4;
template<> int S<5>::i = 5;
template<> int S<6>::i = 6;
template<> int S<7>::i = 7;
template<> int S<8>::i = 8;
template<> int S<9>::i = 9;
template<> int S<10>::i = 10;
template<> int S<11>::i = 11;
template<> int S<12>::i = 12;
template<> int S<13>::i = 13;
template<> int S<14>::i = 14;
template<> int S<15>::i = 15;
template<> int S<16>::i = 16;
template<> int S<17>::i = 17;
template<> int S<18>::i = 18;
template<> int S<19>::i = 19;
template<> int S<20>::i = 20;
template<> int S<21>::i = 21;
template<> int S<22>::i = 22;
template<> int S<23>::i = 23;
template<> int S<24>::i = 24;
template<> const int S<1>::j = -1;