Skip to content

unused warnings can be triggered even though the template is referenced by another template #152395

@ojhunt

Description

@ojhunt

If you have a template in an anonymous namespace we will warn about it being unused even if it is referenced by another template, if the other template is not instantiated.

i.e compiling the following with -Wunused-template

namespace {
  template <class T> void foo(T*){}
}

template <class T> void bar(T* t) {
  foo(t);
}

produces
warning: unused function template 'foo' [-Wunused-template]

The only way to silence this is by using a [[maybe_unused]], which is a solution but is somewhat suboptimal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions