Skip to content

[clang-tidy] modernize-type-traits false positive #67896

Open
@vient

Description

@vient

https://godbolt.org/z/b537zPjo9

namespace std {

template <class a>
struct disjunction : a {};

struct b {
  static int value;
};

template <class>
using c = disjunction<b>;

auto c_v = c<b>::value;

} // namespace std

clang-tidy-17 and current trunk with --checks=modernize-type-traits --extra-arg=-std=c++17 args produce

<source>:13:12: warning: use c++17 style variable templates [modernize-type-traits]
   13 | auto c_v = c<b>::value;
      |            ^   ~~~~~~~
      |             _v
1 warning generated.

In other words, it advises to use c_v in definition of c_v. Renaming std namespace or disjunction struct or value field make the warning go away.

This is problematic if --warnings-as-errors is used, I did not manage to think of a way to bypass this bug other than copying the std::disjunction implementation to my namespace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions