Issue 107610
Summary Clang crashes while generating operator<=>
Labels clang
Assignees
Reporter sabudilovskiy
    ```cpp
#include <compare>
#include <optional>

template <typename T>
struct box {
  T* ptr = nullptr;

  friend constexpr std::strong_ordering operator<=>(const box<T>& lhs, const box<T>& rhs) noexcept {
    if (lhs.ptr && rhs.ptr) {
      return *lhs.ptr <=> *rhs.ptr;
    }
 if (lhs.ptr) {
      return std::strong_ordering::greater;
    }
 if (rhs.ptr) {
      return std::strong_ordering::less;
    }
 return std::strong_ordering::equal;
  }

  friend bool operator==(const box<T>& lhs, const box<T>& rhs);
};

struct TreeNode {
    std::optional<box<TreeNode>> children; 
    constexpr std::strong_ordering operator<=>(const TreeNode&) const;
};

constexpr std::strong_ordering TreeNode::operator<=>(const TreeNode&) const = default;
```

https://godbolt.org/z/71fenezqW
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to