<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63656>63656</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
__is_trivially_equality_comparable gives wrong answer when arrays are involved
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AMP999
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/T6TEavreh
struct S {
std::string a[1];
bool operator==(const S&) const = default;
};
static_assert(__is_trivially_equality_comparable(S)); // oops!
The symptom is that `std::equal` and `std::ranges::equal` produce wrong answers for arrays of `S`.
The root cause is that Clang's (relatively new) builtin `__is_trivially_equality_comparable` incorrectly produces true for `S` when it should produce false. I think `QualType::isTriviallyEqualityComparableType` needs to be updated to check array-element subobjects, as well as member subobjects.
(This is the same issue as #63192, but for a different kind of subobject.)
Thanks to @Quuxplusone for finding this bug
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVMGO4jgQ_ZriUmpknBDCIYfuZpD2sNKOmjuykwrxtmNnXTYs-_UrE4Zp5rKLLCzH5ffqPZdLMZuTI2pg_Qbr3UKlOPjQvP7-x3a7XWjfXZshxomheAW5B7k_-U57G5c-nEDu_wG5P1SHb-ocaACxA_E6_yPHkNqIHwibt_un249jl7GKV47BuBMqWL-tYL2D4ilMe2_RTxRU9AGKXR6ybr3jiB8gK5BbnFdQ7LCjXiUbnzBg8wWTo4qmPSpmChFkfTwaPsZgzkZZez3SX0lZE6_H1o-TCkpbAll_gNzmUbzhrB29nxjk6qvQw0DI13GKfkTDGAcVESrxkHmDhkqgct3TRlDuRPxL0BR8l1rCS_DZG8cXCoy9D6hCUFdG32eQD6jE8id_8D5iqxLTI4V3q9wJ5IYRZB3IqmjOZK_o6JKt08nYaFzG-h9WVAKNa30I1EZ7_ZEkYwyJbsndU8LLQA5NRB58st1DTa8s0xJ_wzgY95mjvydlD9eJZvmGDz_4v93p3x_st7BKoCPqGKNHTZimTkXq8qodqP2c3XkhSyO5iJy0139SGxnkOyrGC1mb55FGTeHL_vLrVYKsD4Ph2UNCVmP2kxPloyCLqlhtZUbUKc53gp3pewqZ89O4Lt_OA3uZS-epUJT7vAmAUnxP6e_JJvZuNrA3rsuvIWZ-nU6Lrim6bbFVC2pWVV2XYlPWxWJoilJ3pVj33YY2K93WctWvNRVKbOtNuS7kwjRSyEJsRLGqRVmK5aYQUvdS1qtW9LpWUAoalbFLa89jfsaLm8amKqp1tbBKk-VbN5DS0WU2AKTMzSE0-cyLTieGUljDkX-iRBMtNf9dTXgyZ-KnCp_r5l7hKhAad_b2TN0iBftr_zFxSHrZ-hHkPpPfp5cp-Gw7yP0tZQa5v0n6NwAA__-ihZWk">