Figure out what to do with flexible array members
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Refactor
- Clarity
- Needs clarification
- Activity status
- Quiet
- Domain
- operating-systems
Research direction
Start by locating the existing Rust definitions that map C flexible array members to public [T; 0] fields, then compare that pattern with unsized [c_char] fields and the listed size_of, offset_of, and reference-use cases. Done means reaching and documenting a decision for the 1.0 representation, with its ABI and usability tradeoffs justified.
Written by the indexing model from the issue text.
Description
A number of C structures make use of a flexible array member:
struct sockaddr {
sa_family_t sa_family; /* Address family */
char sa_data[]; /* Socket address */
};
When mapped to Rust, most of these are a public field of type [T; 0]. We could instead map them to Rust unsized [c_char] fields.
The current pattern has a few advantages over using DSTs:
size_ofworks to get you the base size- You can
offset_ofthe field to get the start of the array if you need it - You can work with the type through references, they don't need to be constructed as fat pointers
- Rust's flexible array members aren't all that convenient to work with
I expect we'll probably want to stick with the current pattern, but it's worth double checking that there isn't something better for 1.0.
- Dominant language
- Rust
- Stars
- 2.6k
- Forks
- 1.3k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 27
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from rust-lang/libc
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
riscv32gc-unknown-linux-gnu: `timex` uses the 32-bit `c_long` layout (144 bytes), glibc's riscv32 `struct timex` is 208 bytesPossibly taken @compiler-segfault claimed this 3 days ago. OpenC-bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
rust-lang/libc#5697 · 3 comments ·
Maintainers usually reply within 1 day
-
Expose `open_how` on AndroidPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
rust-lang/libc#5673 · 1 comment ·
Maintainers usually reply within 1 day
-
RTEMS: `dirfd` is not declaredPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
rust-lang/libc#5655 · 1 comment ·
Maintainers usually reply within 1 day
-
C-bug O-macos
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
rust-lang/libc#5650 · 16 comments ·
Maintainers usually reply within 1 day
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
area:frontend kind:bug priority:p3 ready
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
bug priority: medium ui
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
storytold/vectorcraft#6333 · 1 comment ·
Maintainers usually reply within 1 day
-
bug lexer
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
yara-x fails to build with rsa 0.10.0: unresolved import rsa::Pkcs1v15SignPossibly taken @CfirTsabari claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 87/100
VirusTotal/yara-x#865 ·
Maintainers usually reply within 1 day