Hacker News new | ask | show | jobs
by afdbcreid 24 days ago
It makes a big difference if you want to translate Rust to C. TBAA means you cannot translate a Rust struct to a C struct if you want to stay in standards-compliant C.
1 comments

Can you say more, maybe with an example of what goes wrong? I can't picture this in my head, when I picture translating some struct it feels like this works just fine, clearly I am missing something from what you're imagining.
E.g. you cannot translate `#[repr(C)] struct Foo { v: i32, u: i32 }` to `typedef struct { int32_t v; int32_t u; } Foo;` because in Rust it's entirely valid to take a `&Foo` and view it as `&[i32; 2]`, while in C this is UB.
Isn't the alignment for the struct and the array the same, because it is determined by the inner type?