[PATCH] tst-unique4.cc: Explicitly instantiate S<N>::i
H.J. Lu
hjl.tools@gmail.com
Mon Dec 16 21:58:05 GMT 2024
Explicitly instantiate S<N>::i to silence Clang error:
tst-unique4.cc:8:11: error: instantiation of variable 'S<1>::i' required here, but no definition is available [-Werror,-Wundefined-var-template]
8 | S<1>::i, S<2>::i, S<3>::i, S<4>::i, S<5>::i, S<6>::i, S<7>::i, S<8>::i,
| ^
./tst-unique4.h:5:14: note: forward declaration of template entity is here
5 | static int i;
| ^
tst-unique4.cc:8:11: note: add an explicit instantiation declaration to suppress this warning if 'S<1>::i' is explicitly instantiated in another translation unit
8 | S<1>::i, S<2>::i, S<3>::i, S<4>::i, S<5>::i, S<6>::i, S<7>::i, S<8>::i,
| ^
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
elf/tst-unique4.cc | 49 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/elf/tst-unique4.cc b/elf/tst-unique4.cc
index 575c70d3a1..f38d7c094f 100644
--- a/elf/tst-unique4.cc
+++ b/elf/tst-unique4.cc
@@ -3,6 +3,55 @@
#include <cstdio>
+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;
+
static int a[24] =
{
S<1>::i, S<2>::i, S<3>::i, S<4>::i, S<5>::i, S<6>::i, S<7>::i, S<8>::i,
--
2.47.1
More information about the Libc-alpha
mailing list