[llvm-bugs] [Bug 50877] New: Wzero-as-null-pointer-constant when using defaulted operator<=>

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 25 18:34:02 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50877

            Bug ID: 50877
           Summary: Wzero-as-null-pointer-constant when using defaulted
                    operator<=>
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mike.winterberg at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Created attachment 24983
  --> https://bugs.llvm.org/attachment.cgi?id=24983&action=edit
possible patch for the problem

See bug https://bugs.llvm.org/show_bug.cgi?id=44325 for what is happening that
produces the 0 -> nullptr conversion.

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

#include <compare>
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210626/ef7681aa/attachment.html>


More information about the llvm-bugs mailing list