<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/86384>86384</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Crash in QList.append() on Windows ARM64
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
triplef
</td>
</tr>
</table>
<pre>
Using Clang 18.1.2 WoA on Windows ARM64 results in a failed assertion when adding more than 2 items to a QList due to the assertion [Q_ASSERT(!data || !data->isShared())](https://github.com/qt/qtbase/blob/98602c26fc97eb41e3dd7548194ca637420a31b9/src/corelib/tools/qarraydata.cpp#L229) failing in QArrayData::reallocateUnaligned. We reproduced the issue with both Clang 17 and 18 and Qt 6.5, 6.6, and 6.7.
```c++
QList<QString> list;
list.append("ONE");
list.append("TWO");
list.append("THREE"); // CRASH
```
In this debug session the value of the data pointer changes by `0x10` when calling ArrayData::reallocateUnaligned():
- `0x000002b224a0bdb0` before `reallocateUnaligned()`
- `0x000002b224a0bdc0` in `reallocateUnaligned()`
This pointer misalignment causes an invalid value for `ref_`, causing `isShared()` to return true.
Before:

After:

We [submitted](https://bugreports.qt.io/browse/QTBUG-123617) the bug to Qt and got the following feedback:
> `QTypedArrayData` is-a `QArrayData` so the compiler is required to adjust the pointer to the base sub-object when casting. However, in this case, we expect and require that adjustment to be zero. `QTypedArrayData` adds no other members, so it has exactly the same size and alignment requirements as `QArrayData`. In fact, we actually static_assert the size equality in one of the two screenshots.
> I actually don't think the issue is the adjustment of the base sub-object. This appears to be a codegen issue in selecting registers. Look at dataPointer at `0x18`, which is not a valid pointer, but is `sizeof(QString)`, the next parameter. objectSize is listed as 3, which is not a valid size for `QString`, but is a valid flag combination. The 0x10 difference between caller and callee is explained by the fact that it is also the difference between data and dataPointer.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVk1v4zgS_TX0pWBBor4PPjhOst1A786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