-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disallow duplicated extern declarations #12707
Comments
This would disallow duplicate functions with different signatures, but still allow duplicate with the same? |
I thought identical duplicates are ok because |
This fixes struct passing abi on x86 ffi: Structs are now passed indirectly with byval attribute (as clang does).
Modified test case causing llvm assertion error on x64: mod a {
extern {
fn func(); // declare void @func() unnamed_addr
}
}
mod b {
struct S {
a: u64,
b: u64,
c: u64,
}
extern {
fn func(s: S); // declare void @func(%"struct.b::S"* byval) unnamed_addr
}
}
In the case, argument has |
cc #12762: |
klutzy's test case is causing a different error now on 64-bit Linux:
Are duplicate declarations useful/necessary for calling functions like |
Traige: Still getting the same failure as @rprichard , but I'm also on x86-64. Does this fail everywhere now? |
On x86-64 as well, does not reproduce with |
Triage: no change |
The rustc compiler does throw warnings when we use two conflicting function signatures in extern declarations. So, shall we change this to disallow it and instead throw an error? |
|
…omcc Refactor uses of `objc_msgSend` to no longer have clashing definitions This is very similar to what Apple's own headers encourage you to do (cast the function pointer before use instead of making new declarations). Additionally, I'm documenting a few of the memory management rules we're following, ensuring that the `args` function doesn't leak memory (if you wrap it in an autorelease pool). Motivation is to avoid issues with clashing definitions, like described in rust-lang#12707 (comment) and rust-lang#46188 (comment), CC `@bjorn3.`
…omcc Refactor uses of `objc_msgSend` to no longer have clashing definitions This is very similar to what Apple's own headers encourage you to do (cast the function pointer before use instead of making new declarations). Additionally, I'm documenting a few of the memory management rules we're following, ensuring that the `args` function doesn't leak memory (if you wrap it in an autorelease pool). Motivation is to avoid issues with clashing definitions, like described in rust-lang#12707 (comment) and rust-lang#46188 (comment), CC ``@bjorn3.``
Rollup merge of rust-lang#117910 - madsmtm:msg-send-no-clashing, r=thomcc Refactor uses of `objc_msgSend` to no longer have clashing definitions This is very similar to what Apple's own headers encourage you to do (cast the function pointer before use instead of making new declarations). Additionally, I'm documenting a few of the memory management rules we're following, ensuring that the `args` function doesn't leak memory (if you wrap it in an autorelease pool). Motivation is to avoid issues with clashing definitions, like described in rust-lang#12707 (comment) and rust-lang#46188 (comment), CC ``@bjorn3.``
Since #117910, this is no longer true, instead we explicitly cast the function pointer (which is arguably the more correct behaviour, at least it's what the C headers also declare and expect you to do). |
Currently rustc accepts this, but I think it should be disallowed to reduce potential mistakes.
The text was updated successfully, but these errors were encountered: