Skip to content

Conversation

HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented Feb 26, 2024

Fixes #9873. Section 3.2.3 of the System V ABI reference says: (emphasis own)

The classification of aggregate (structures and arrays) and union types works as follows:

  1. If the size of an object is larger than eight eightbytes, or it contains unaligned fields, it has class MEMORY.

The same behavior is verified with C on Clang. Actually calling Procs that take or return those misaligned structs will most likely require #14323 as well, as byval and sret are now mandatory.

On an unrelated note: while the reference says "eight eightbytes", an earlier revision said "four" instead, which is what Crystal currently uses for classification. This probably won't matter unless Crystal supports 512-bit vectors natively.

@HertzDevil HertzDevil added kind:bug A bug in the code. Does not apply to documentation, specs, etc. platform:unix platform:x86 topic:stdlib:llvm labels Feb 26, 2024
@straight-shoota straight-shoota added this to the 1.12.0 milestone Feb 26, 2024
@straight-shoota straight-shoota merged commit 81fa3a9 into crystal-lang:master Feb 27, 2024
@HertzDevil HertzDevil deleted the bug/x86-64-misaligned-struct branch February 29, 2024 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:bug A bug in the code. Does not apply to documentation, specs, etc. platform:unix platform:x86 topic:stdlib:llvm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Internal compiler error when lib fun takes or returns packed struct by value

2 participants