<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/119290>119290</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`std::has_unique_object_representations_v<>` does not work correctly with `vector_size` attribute
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pkasting
</td>
</tr>
</table>
<pre>
Clang supports the gcc `vector_size` attribute, but `std::has_unique_object_representations_v<>` seems to work incorrectly with it.
This attribute allows declaring a vector object of a given byte size, divided into integral or floating units. The total size must be a positive power of 2 multiple of the unit size, so there are no implicit padding bytes. Vector objects may be compared, and the result is another vector with element-wise comparison results. Representationally, the elements of the result vector are 0 if the comparison succeeded and -1 otherwise. So comparing `vec == vec` gives all zeroes.
Per cppreference, this type trait is supported for arbitrary objects, including arrays, which are considered equal if they are per-element equal. Vector objects would presumably be treated similarly. Therefore, I'd expect vectors to have a unique representation iff their base types are integral.
However, they aren't marked that way. Example: https://godbolt.org/z/r6Thv3v65
Here, there is a single-element vector whose base type is a uint32_t. It is correctly marked trivially-copyable. However, it is falsely marked as not having a unique obj representation.
I wonder if the strange comparison result for == (0 for ==, -1 for !=) is throwing things off. At least the cppreference text does not specify in terms of comparison results being zero/false/etc., but on the values being equal. So I would assume there needs to be some custom handling of vector types in the compiler here.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVUFz2zgP_TX0BRONRSVxfPAhX1rPl9vOtrPXDEVBElqKVAlIrvrrd0jJSdru7GEv9ogkgIf3HkjDTJ1HPKm7_6m7DzszSR_iafxqWMh3uzo0y-nJGd8BT-MYojBIj9BZC-p-P6OVEF-YfqC634MRiVRPgko_QT1JOsLSqOpRVY-94ZfJ07cJX0L9Ba28RBwjMnoxQsHzy6yqJ1V9TJkYcWCQAJcQvwJ5G2JEK26BC0kPJIXaP6r94-ee-K0sGOfChaFB60wk34GB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