tree_code orig_code0 = TREE_CODE (orig_type0);
tree orig_type1 = TREE_TYPE (orig_op1);
tree_code orig_code1 = TREE_CODE (orig_type1);
- if (!result_type)
- /* Nope. */;
+ if (!result_type || result_type == error_mark_node)
+ /* Nope. */
+ result_type = NULL_TREE;
else if ((orig_code0 == BOOLEAN_TYPE) != (orig_code1 == BOOLEAN_TYPE))
/* "If one of the operands is of type bool and the other is not, the
program is ill-formed." */
--- /dev/null
+// PR c++/107542
+// { dg-do compile { target c++20 } }
+
+#include <compare>
+
+template<class T, class U>
+concept same_as = __is_same(T, U);
+
+template<class Lhs, class Rhs>
+concept Ord = requires(Lhs lhs, Rhs rhs) {
+ { lhs <=> rhs } -> same_as<std::strong_ordering>;
+};
+
+static_assert(Ord<int*, int*>); // Works.
+static_assert(!Ord<int*, char*>); // ICE.
+
+template<class T>
+struct S {
+ T* p;
+};
+
+template<class T, class U>
+ requires(Ord<const T*, const U*>)
+constexpr inline auto operator<=>(const S<T>& l, const S<U>& r) noexcept {
+ return l.p <=> r.p;
+}
+
+static_assert(Ord<S<int>, S<int>>); // Works.
+static_assert(!Ord<S<int>, S<char>>); // ICE.