[llvm-bugs] [Bug 50591] New: wrong comparison category/crash involving user-defined conversions to builtin types

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jun 5 18:19:19 PDT 2021


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: unassignedclangbugs at nondot.org
          Reporter: mizvekov 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

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210606/0a883e17/attachment-0001.html>


More information about the llvm-bugs mailing list