Skip to content

Wzero-as-null-pointer-constant when using defaulted operator<=> #50221

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
mwinterb mannequin opened this issue Jun 26, 2021 · 1 comment
Closed

Wzero-as-null-pointer-constant when using defaulted operator<=> #50221

mwinterb mannequin opened this issue Jun 26, 2021 · 1 comment
Assignees
Labels
bugzilla Issues migrated from bugzilla c++20 clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer

Comments

@mwinterb
Copy link
Mannequin

mwinterb mannequin commented Jun 26, 2021

Bugzilla Link 50877
Version trunk
OS Windows NT
Attachments possible patch for the problem
CC @zygoloid

Extended Description

See bug #43670 for what is happening that produces the 0 -> nullptr conversion.

Compiling this code with -Wzero-as-null-pointer-constant

#include
struct Point {
int x{}, y{}, z{};
auto operator<=>(const Point&) const = default;
};

int main() {
return Point{} < Point{};
}

Produces three -Wzero-as-null-pointer-constant warnings, one for each member of Point. Fortunately suppressing the warning at the implementation site of operator<=> suppresses it for users.

Live example: https://gcc.godbolt.org/z/3n9Kf3baa

The fix is seemingly very close the fix to #​44325, but the build environment I have that can build clang doesn't have "enough" to actually run the tests so I don't know if my possible fix ends up suppressing the warning in other cases.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@ilya-biryukov
Copy link
Contributor

Related issue in clang-tidy: #53961

@EugeneZelenko EugeneZelenko added the clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer label Nov 24, 2022
@jensmassberg jensmassberg self-assigned this Nov 26, 2022
@jensmassberg jensmassberg moved this to Done in C++ 20 in Clang Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++20 clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Projects
Status: Done
Development

No branches or pull requests

3 participants