rust-lang / rust-lang/rust-bindgen
Disallow passing `_Complex` by value
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
As seen in https://github.com/rust-lang/rfcs/issues/793 and https://github.com/rust-lang/libc/issues/355, C’s _Complex has a different ABI (but not layout) to what Bindgen currently generates, which is:
#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)]
#[repr(C)]
pub struct __BindgenComplex<T> {
pub re: T,
pub im: T,
}
As a soundness fix, I suggest erroring when the user attempts to use _Complex by value. Maybe this could be done with a flag to disable it if the user really wants the potentially-unsound behaviour?
Contributor 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.
Research direction
Start by tracing bindgen's handling of C _Complex and read the referenced Rust RFC and libc issue for the ABI distinction. Determine where by-value uses are represented and how related diagnostics are tested. Done means such uses are rejected, with the issue's proposed opt-out behavior resolved explicitly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100