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

            Bug ID: 50591
           Summary: wrong comparison category/crash involving user-defined
                    conversions to builtin types
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangb...@nondot.org
          Reporter: mizve...@gmail.com
                CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
                    llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk

Wrong comparison category is produced for classes with defaulted spaceship
operator which contain members with user-defined conversion operator to
integral type.
For builds with assertions enabled, this produces a crash instead for
conversions to any builtin type.

Reproduction:
```
#include <compare>

struct a1 {
  operator int() const;
};
struct b1 {
  auto operator<=>(b1 const &) const = default;
  a1 f;
};
std::strong_ordering cmp_b1 = b1() <=> b1();
```

This will either result in:
* Incorrect diagnostic: error: no viable conversion from
'std::partial_ordering' to 'std::strong_ordering'
* Crash when assertions are enabled: Assertion failed: Cat && "no category for
builtin comparison?", file SemaDeclCXX.cpp

Workspace for convenience: https://godbolt.org/z/EasTWssje

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to