__attribute__((sentinel)) for C FFI variadic functions
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
__attribute__((sentinel)) or __attribute__((sentinel(N))) is a GNU C extension (also supported by clang) that marks variadic functions as requiring a sentinel NULL value in the last (or (N+1)th-to-last) argument slot. The compiler checks uses of this function and emits a warning (-Wformat) if the NULL sentinel value is not present in the expected location in the parameter list.
It would be nice to be able to mark foreign variadic functions in Rust the same way, such that the compiler checks that a sentinel NULL appears in the proper position at call sites for these functions. GCC considers any 0-initialized pointer type to be NULL in this context.
Contributor guide
No contributing guide indexed for this repository
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
Start by reviewing the requested Rust support and the linked GCC sentinel attribute documentation. Determine how the attribute should be represented for foreign variadic functions, which argument positions are valid, and how call-site diagnostics should behave; done means the semantics and implementation scope are defined well enough for an RFC or compiler change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100