rust-lang / rust-lang/libc

ctest: Support flexible array members

Open
#5,369 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ctest
Dominant language
Rust
Stars
2.6k
Forks
1.3k
Avg merge
1d 22h
Merged PRs (30d)
69

Description

C's "flexible array members" are basically a convenient way to access a properly-aligned pointer to data after the struct:

struct s {
    int len;
    int data[];
};

In Rust we typically do:

struct S {
    len: c_int,
    data: [c_int; 0],
}

We have a handful of tests that are related to FAM not being supported, e.g. https://github.com/rust-lang/libc/blob/93a17ee8f6cb91cd73dbfd7c5bad88f67dc16164/libc-test/build.rs#L5338-L5345. I think this should be pretty easy to start supporting.

Cc of course @mbyx

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in libc-test/build.rs around lines 5338-5345, then inspect the other tests related to flexible array members not being supported. Trace how ctest handles the Rust representation of C flexible array members and update that support. Done means the relevant libc tests recognize the shown zero-length-array pattern and pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
testing-qa
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
66/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.