Wzero-as-null-pointer-constant when using defaulted operator<=> #50221
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
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.
The text was updated successfully, but these errors were encountered: