[clang] fix: compatible C++ empty record with align UB with gcc (PR #72197)
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 15 14:27:18 PST 2023
rjmccall wrote:
First off, the change here actually applies to all over-aligned empty structs, not just to those with aligned bit-fields. Maybe we can say that aligned zero-width bit-fields are ill-formed, but I don't think we can say that all aligned empty classes are ill-formed, among other things because I'm pretty sure they're explicitly allowed in C++. So let's just set the aligned bit-field question aside for a moment.
Second, I don't understand why the fix is to `isEmptyRecord`. This is a very general routine that affects a lot of code in a lot of targets. And for most of those purposes, I think an aligned empty class should still be considered an empty record. I think we need to understand why this is fixing the bug.
Third, it does look like we have a real ABI bug here. I haven't looked at other targets, but at least on AArch64, a 16-byte-aligned empty class should definitely be taking up two registers. For some reason, we are generating IR to pass this class as a single byte rather than as a number of bytes equal to its size.
Finally, as usual, some platforms may want to opt out of this ABI break; I'll ask around at Apple.
https://github.com/llvm/llvm-project/pull/72197
More information about the cfe-commits
mailing list