Missing FFI type safety checks
Open
Nobody has claimed this yet.
bug
diagnostic
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 20h 2m
- Merged PRs (30d)
- 66
Description
I tried this code: https://github.com/rust-lang/rust/blob/aa3ca1994904f2e056679fce1f185db8c7ed2703/src/test/ui/issue-14309.rs
https://godbolt.org/z/GjGG3jTh4
struct A {
x: i32
}
#[repr(C, packed)]
struct B {
x: i32,
y: A
}
#[repr(C)]
struct C {
x: i32
}
type A2 = A;
type B2 = B;
type C2 = C;
#[repr(C)]
struct D {
x: C,
y: A
}
extern "C" {
fn foo(x: A); //~ ERROR type `A` which is not FFI-safe
fn bar(x: B); //~ ERROR type `A`
fn baz(x: C);
fn qux(x: A2); //~ ERROR type `A`
fn quux(x: B2); //~ ERROR type `A`
fn corge(x: C2);
fn fred(x: D); //~ ERROR type `A`
}
fn main() { }
I expected to see this happen: errors that type 'A' is not FFI-safe
Instead, this happened: compile-without error
Meta
- What version of Rust GCC were you using, git sha if possible. be27571c110d99fe55324a9c2b6622787b08fb52
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 reproducing the example from src/test/ui/issue-14309.rs with the reported Rust GCC revision, using the linked Godbolt case if helpful. Trace the compiler's FFI-safety diagnostics for A, packed B, aliases A2/B2, and nested D; done means the expected errors are emitted while C and C2 remain accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100