Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
MikeWeller opened this issue Apr 9, 2024 · 3 comments · Fixed by #88138
Closed

Comments

@MikeWeller
Copy link
Contributor

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.
@MikeWeller
Copy link
Contributor Author

If anyone can point me to the relevant source I can have a go at a fix.

@MikeWeller
Copy link
Contributor Author

Thanks, working on a fix now.

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

Successfully merging a pull request may close this issue.

2 participants