Skip to content

ctest: Support flexible array members #5369

Description

@tgross35

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.

libc/libc-test/build.rs

Lines 5338 to 5345 in 93a17ee

// The following types contain Flexible Array Member fields which have unspecified calling
// convention. The roundtripping tests deliberately pass the structs by value to check "by
// value" layout consistency, but this would be UB for the these types.
"inotify_event" => true,
"fanotify_event_info_fid" => true,
"cmsghdr" => true,
"bcm_msg_head" => true,
. I think this should be pretty easy to start supporting.

Cc of course @mbyx

Metadata

Metadata

Assignees

No one assigned

    Labels

    ctestIssues relating to the ctest crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions