From d37cc4ad4209ccb5aa006db60e3e1c4dd393c9f1 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Mon, 9 Feb 2026 19:13:46 +0100 Subject: [PATCH] [tmva][sofie] Fix compiler warning in tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The last commit that changed the tests left a compiler warning: ```txt In file included from /home/rembserj/code/root/root_src/tmva/sofie/test/TestCustomModelsFromONNX.cxx:3: /home/rembserj/code/root/root_src/tmva/sofie/test/test_helpers.h: In instantiation of ‘OutputType_t runModel(std::string, const std::string&, std::string, const Ts& ...) [with OutputType_t = std::vector; Ts = {}; std::string = std::__cxx11::basic_string]’: /home/rembserj/code/root/root_src/tmva/sofie/test/TestCustomModelsFromONNX.cxx:318:4: required from here 130 | auto output = runModel(#OutputType, _modelName, ""); | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/rembserj/code/root/root_src/tmva/sofie/test/test_helpers.h:74:9: warning: variable ‘type_name’ set but not used [-Wunused-but-set-variable] 74 | auto type_name = []() { | ^~~~~~~~~ /home/rembserj/code/root/root_src/tmva/sofie/test/test_helpers.h:107:9: warning: variable ‘first’ set but not used [-Wunused-but-set-variable] 107 | bool first = true; | ^~~~~ cc1plus: note: unrecognized command-line option ‘-Wno-unused-command-line-argument’ may have been intended to silence earlier diagnostics ``` This can be avoided by guarding the parameter pack expension in an if clause that checks if the size of the parameter pack is not empty. --- tmva/sofie/test/test_helpers.h | 53 ++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/tmva/sofie/test/test_helpers.h b/tmva/sofie/test/test_helpers.h index fd89279257fea..20a121d34ed72 100644 --- a/tmva/sofie/test/test_helpers.h +++ b/tmva/sofie/test/test_helpers.h @@ -70,22 +70,6 @@ runModel(std::string outputTypeName, std::string const &modelName, std::string s outputTypeName = "std::tuple, std::vector>"; } - // Helper: map C++ type -> string used in interpreter - auto type_name = []() { - if constexpr (std::is_same_v) - return "int"; - else if constexpr (std::is_same_v>) - return "std::vector"; - else if constexpr (std::is_same_v>) - return "std::vector"; - else if constexpr (std::is_same_v>) - return "std::vector"; - else if constexpr (std::is_same_v>) - return "std::vector"; - else - static_assert(!sizeof(T), "Input type not supported"); - }; - std::stringstream cmd; if (sessionArgs.empty()) { @@ -104,15 +88,34 @@ runModel(std::string outputTypeName, std::string const &modelName, std::string s } // Emit all inputs to s.infer(...) - bool first = true; - ( - [&] { - if (!first) - cmd << ", "; - first = false; - cmd << toInterpreter(inputs, type_name.template operator()(), true); - }(), - ...); + if constexpr (sizeof...(Ts) > 0) { + + // Helper: map C++ type -> string used in interpreter + auto type_name = []() { + if constexpr (std::is_same_v) + return "int"; + else if constexpr (std::is_same_v>) + return "std::vector"; + else if constexpr (std::is_same_v>) + return "std::vector"; + else if constexpr (std::is_same_v>) + return "std::vector"; + else if constexpr (std::is_same_v>) + return "std::vector"; + else + static_assert(!sizeof(T), "Input type not supported"); + }; + + bool first = true; + ( + [&] { + if (!first) + cmd << ", "; + first = false; + cmd << toInterpreter(inputs, type_name.template operator()(), true); + }(), + ...); + } cmd << R"(); std::swap(output, *)"