From 080a320914e2026c2d4cfbf91d523b079ae4fc94 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 17 Dec 2024 05:57:49 +0800 Subject: [PATCH] tst-unique3.cc: Add explicit instantiation declaration for S::i Add explicit instantiation declaration of S::i to silence Clang error: tst-unique3.cc:6:18: error: instantiation of variable 'S::i' required here, but no definition is available [-Werror,-Wundefined-var-template] 6 | int t = S::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::i' is explicitly instantiated in another translation unit 6 | int t = S::i; | ^ Signed-off-by: H.J. Lu --- elf/tst-unique3.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/elf/tst-unique3.cc b/elf/tst-unique3.cc index efdd6d78c2..bce3e578d7 100644 --- a/elf/tst-unique3.cc +++ b/elf/tst-unique3.cc @@ -3,6 +3,9 @@ #include #include "../dlfcn/dlfcn.h" +template<> +int S::i; + int t = S::i; int