Skip to content

Clang-Tidy: modernize-use-nullptr does not make sense with spaceship operator #53961

Closed
@pavelkryukov

Description

@pavelkryukov

Reopening #45580, as the problem was not solved:

https://godbolt.org/z/3hed7vPvM

#include <compare>

struct A {
  int a;
  constexpr auto operator<=>(const A&) const = default;
};

bool foo(A x, A y) { return x < y; }

Command line:

clang-tidy-13 -checks='hicpp-use-nullptr' tidy20.cpp -- -std=c++20

Output:

<source>:5:56: warning: use nullptr [hicpp-use-nullptr]
    constexpr auto operator<=>(const A&) const = default;
                                                       ^
                                                        nullptr

Also, for strange reasons I cannot escape it with NOLINTNEXTLINE with local clang-tidy-13.
Godbolt's trunk version suppresses warning correctly.

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorc++20clang-tidyconfirmedVerified by a second party

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions