`homogeneous_aggregate` does not consider empty arrays
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
In C, at least on aarch64-unknown-linux-gnu and powerpc64le-unknown-linux-gnu, an empty array field disqualifies a struct from being a HFA
https://godbolt.org/z/heMqY94fG
struct Yes { float a; float b; };
struct No { float a; float b; char z[0]; };
float yes(struct Yes s) { return s.b; }
float no(struct No s) { return s.b; }
yes:
fmov s0, s1
ret
no:
lsr x8, x0, #32
fmov s0, w8
ret
Rust does not disqualify the struct when it has a zero-sized array member:
https://godbolt.org/z/W5e3asGz9
#[repr(C)]
struct Yes {
a: f32,
b: f32,
}
#[repr(C)]
struct No {
a: f32,
b: f32,
z: [u8; 0],
}
#[unsafe(no_mangle)]
extern "C" fn yes(s: Yes) -> f32 { s.b }
#[unsafe(no_mangle)]
extern "C" fn no(s: No) -> f32 { s.b }
no:
fmov s0, s1
ret
yes = no
This seems unlikely to come up in practice, given that ZSTs in C are used very infrequently.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named. Start by reproducing the C and Rust examples on aarch64-unknown-linux-gnu and powerpc64le-unknown-linux-gnu, then trace homogeneous_aggregate classification for zero-sized array members. Done means the ABI behavior is consistent and covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100