Skip to content

ctest: support flexible array members - #5620

Open
Deepak-negi11 wants to merge 1 commit into
rust-lang:mainfrom
Deepak-negi11:ctest-fam
Open

Deepak-negi11 wants to merge 1 commit into
rust-lang:mainfrom
Deepak-negi11:ctest-fam

Conversation

@Deepak-negi11

@Deepak-negi11 Deepak-negi11 commented Oct 11, 2026 •

Copy link
Copy Markdown

Fixes #5369

ctest couldn't test fields like uint8_t data[] (we write them as [T; 0]), so libc-test was skipping them.

What I changed:

  • ctest skips only the size check for [T; 0] fields, since C can't do sizeof on them. offset and type are still checked
  • [T; 0] is now written as T[] in the generated C, because MSVC errors on [0] arrays
  • added a VarBuf struct to the ctest tests. I skipped its roundtrip test because it segfaulted on FreeBSD when passed by value
  • removed the FAM skips in libc-test (dirent.d_name on wasi, iw_encode_ext.key, fanotify_event_info_fid.handle, mcontext_t.__extcontext on musl loongarch64, bcm_msg_head.frames, af_alg_iv.iv, file_handle.f_handle)

I didn't touch roundtrip for the libc structs. not sure if ctest should skip those automatically, let me know and I can do it separately.

I ran the full CI on my fork and the tests passed: https://github.com/Deepak-negi11/libc/actions/runs/38123417531 (only Verify build failed there, because it needs main as the base branch)

  • Relevant tests in ctest/tests and ctest/src/tests.rs have been updated
  • Tested locally (LIBC_BLESS=1 cargo test -p ctest)

@rustbot rustbot added ctest Issues relating to the ctest crate S-waiting-on-review labels Oct 11, 2026
Copilot AI balanced review requested due to automatic review settings October 11, 2026 09:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Skip the field size test for [T; 0] fields, since C can't sizeof a T[] field. Translate [T; 0] as T[] because MSVC rejects zero-length arrays. Remove the flexible array member skips in libc-test.

Fixes rust-lang#5369

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ctest Issues relating to the ctest crate S-waiting-on-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ctest: Support flexible array members

3 participants