Skip to content

clang-tidy bugprone-forwarding-reference-overload false positive on = delete; constructor #88128

Closed
@MikeWeller

Description

The bugprone-forwarding-reference-overload check in clang-tidy will warn even for a = delete; constructor:

// main.cpp
class Foo {
public:
  // ...

  template <typename T>
  Foo(T&&) = delete;

  // ...
};
clang-tidy -checks=bugprone-* main.cpp

/path/to/main.cpp:5:3: warning: constructor accepting a forwarding reference can hide the copy and move constructors [bugprone-forwarding-reference-overload]
    5 |   Foo(T&&) = delete;
      |   ^

In our case, we had various templated constructors and it looks like the original author decided to explicitly delete this to warn/prevent somebody making this mistake in the future.

$ clang-tidy --version
LLVM (http://llvm.org/):
  LLVM version 17.0.6
  Optimized build.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions