Need help to fix some -Wunused-template dashboard warnings

Hi all,

Any C++ experts out there that could help fix these 2 warnings:

ITK/Modules/Core/Common/include/itkMath.h:524:1: warning: unused function template ‘AlmostEqualsScalarComparer’ [-Wunused-template]
AlmostEqualsScalarComparer( TScalarType1 x1, TScalarType2 x2 )
^

ITK/Modules/Core/Common/include/itkVersor.hxx:590:28: warning: unused function template ‘localTransformVectorMath’ [-Wunused-template]
const OutputVectorType localTransformVectorMath(const InputVectorType & VectorObject,
^

I think it has something to do with ODR violation checking, but I’m no C++ expert…

Thanks,

I believe I have seen this warning before with “static” template functions and template functions in anonymous namespaces. If the static key word is removed then the warning goes away. You could still specify hidden linkage if really needed.

Some of them are static, and some are not. Those that are not all seem to be in anonymous namespaces…

Do you have a simple example that reproduces these warnings that you could share?

Looking at the history of the file where I struggled with this warning there were a couple different issues that may have been causing problem. I believe this patch was the one that addressed the warning for me:

Contrary to what I initially said, this appear to have added the ‘inline’ keyword to the function.

You mean something stripped down? No, I don’t. I’m trying to get my dashboards green, and there are a few -Wunused-template warnings, see:

https://open.cdash.org/viewBuildError.php?type=1&buildid=5118773

Cheers,

From this stackoverflow question: c++ - Suppress Compiler warning Function declared never referenced - Stack Overflow

I see two answers that are very interesting: The first one:

-Wunused-function
Warn whenever a static function is declared but not defined or a non-inline static function is unused. This warning is enabled by -Wall.

Which is followed by the comment:

static inline doesn’t (always) suppress this for clang. – robertwb Nov 16 '16 at 0:52

From your dashboard result, I see that you are using clang, which might explain why the solution given by @blowekamp does solve the issue completely.

Now there is another solution that I think is interesting for this question:

void foo (int, int) attribute ((unused));

It would be interesting to set this attribute and see if that solves your issue. We could then create a patch for ITK if that works.