Skip to content

Clang-Tidy raises modernize-use-nullptr with spaceship operator #64159

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

Closed
andrea-cassioli-maersk opened this issue Jul 27, 2023 · 4 comments
Closed
Labels
clang-tidy duplicate Resolved as duplicate false-positive Warning fires when it should not

Comments

@andrea-cassioli-maersk
Copy link

Reopening #53961 as it seems to me the issue is not solved.

I have a simple struct


#include <compare>

struct X {
  double a = 0.0;
  double b = 0.0;
  double c = 0.0;

  X() = default;
  X(const X&) = default;
  explicit X(double x);

  X& operator=(const X& other) = default;
  // NOLINTNEXTLINE(modernize-use-nullptr)
  std::partial_ordering operator<=>(const X&) const = default;
};

if I run clang-tidy I get an error

Resource filename: /opt/homebrew/lib/python3.11/site-packages/clang_tidy/data/bin/clang-tidy 
/Users/***/***.h:23:77: error: use nullptr [modernize-use-nullptr,-warnings-as-errors]
  std::partial_ordering operator<=>(const X&) const = default;
                                                                            ^
                                                                             nullptr

Am I missing anything here?

@EugeneZelenko EugeneZelenko added clang-tidy false-positive Warning fires when it should not and removed new issue labels Jul 27, 2023
@llvmbot
Copy link
Member

llvmbot commented Jul 27, 2023

@llvm/issue-subscribers-clang-tidy

@PiotrZSL
Copy link
Member

Looks like warning is generated in system header:

include/c++/14.0.0/compare:364:21: warning: use nullptr [modernize-use-nullptr]
  364 |   { return __cmp != 0; }

Do not use --system-header to silent it.
Anyway, duplicate of #63478

@EugeneZelenko EugeneZelenko added the duplicate Resolved as duplicate label Jul 27, 2023
@EugeneZelenko EugeneZelenko closed this as not planned Won't fix, can't repro, duplicate, stale Jul 27, 2023
@andrea-cassioli-maersk
Copy link
Author

hey @PiotrZSL I am not sure I understand your suggestion.

@PiotrZSL
Copy link
Member

PiotrZSL commented Jul 28, 2023

I mean that those issues are raised in system header, and looks like --warnings-as-errors is causing it to be visible. This issue (check filters) can be already fixed in Clang 17. As for bug in check, that is pending.

Most probably if you disable warnings-as-errors, you wont see this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang-tidy duplicate Resolved as duplicate false-positive Warning fires when it should not
Projects
None yet
Development

No branches or pull requests

4 participants