-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ABI mismatch between MSVC and Clang when returning std::pair
on Windows ARM64
#86384
Comments
We are linking against official Qt releases built with MSVC. Further feedback from Qt:
|
@triplef I have looked into this and can confirm it as a ABI mismatch between MSVC and Clang. This could be a Clang/LLVM bug because it promises to be ABI compatible with MSVC. But there are some exception to this compatibility. I am not aware of those exceptions so lets ask some experts. @mstorsjo @compnerd do you know if this is a deliberately left incompatibility or this is a bug? |
I would definitely consider this a bug - I don't think we'd leave such things incompatible deliberately. |
If you are using |
I tested following c++ code:
Function returnPair epilogue generated by both compiler is given below: ASM generated by MS cl Compiler Version 19.37.32824 for ARM64.
ASM generated by clang-cl 17.0.6 WoA64 upstream release build.
MS cl is setting up return value address in x0 while clang-cl is setting up pair of values in x0 and x1 |
@llvm/issue-subscribers-clang-codegen Author: Frederik Seiffert (triplef)
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.
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
This pointer misalignment causes an invalid value for We submitted the bug to Qt and got the following feedback: > |
std::pair
on Windows ARM64
This I think somewhat related issue #88273 points to https://reviews.llvm.org/D60348 implementing struct returns on ARM64. ARM64 ABI docs about return values: |
Reduced:
|
In the context of determining whether a class counts as an "aggregate", a constructor template counts as a user-provided constructor. Fixes llvm#86384
/cherry-pick 3ab4ae9 |
…lvm#90151) In the context of determining whether a class counts as an "aggregate", a constructor template counts as a user-provided constructor. Fixes llvm#86384 (cherry picked from commit 3ab4ae9)
/pull-request #90639 |
…lvm#90151) In the context of determining whether a class counts as an "aggregate", a constructor template counts as a user-provided constructor. Fixes llvm#86384 (cherry picked from commit 3ab4ae9)
…lvm#90151) In the context of determining whether a class counts as an "aggregate", a constructor template counts as a user-provided constructor. Fixes llvm#86384 (cherry picked from commit 3ab4ae9)
…lvm#90151) In the context of determining whether a class counts as an "aggregate", a constructor template counts as a user-provided constructor. Fixes llvm#86384 (cherry picked from commit 3ab4ae9)
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()) failing in QArrayData::reallocateUnaligned. We reproduced the issue with both Clang 17 and 18 and Qt 6.5, 6.6, and 6.7.
In this debug session the value of the data pointer changes by
0x10
when calling ArrayData::reallocateUnaligned():0x000002b224a0bdb0
beforereallocateUnaligned()
0x000002b224a0bdc0
inreallocateUnaligned()
This pointer misalignment causes an invalid value for
ref_
, causingisShared()
to return true.Before:

After:

We submitted the bug to Qt and got the following feedback:
The text was updated successfully, but these errors were encountered: