]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
tst-unique3.cc: Add explicit instantiation declaration for S<char>::i
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 16 Dec 2024 21:57:49 +0000 (05:57 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 17 Dec 2024 18:06:17 +0000 (02:06 +0800)
Add explicit instantiation declaration of S<char>::i 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>
elf/tst-unique3.cc

index efdd6d78c2cc016085263912c5f786b402ac6139..bce3e578d791a9abf63901d84e585153f026b4f2 100644 (file)
@@ -3,6 +3,9 @@
 #include <cstdio>
 #include "../dlfcn/dlfcn.h"
 
+template<>
+int S<char>::i;
+
 int t = S<char>::i;
 
 int