I tried this code:
unsafe extern "C" {
fn exit(s: i32);
}
fn main() {
unsafe { exit(5); }
}
I expected to see this happen: Compilation succeed and program returned 5
Instead, this happened:
error: invalid definition of the runtime `exit` symbol used by the standard library
--> <source>:4:5
|
4 | fn exit(s: i32);
| ^^^^^^^^^^^^^^^^
|
= note: expected `unsafe extern "C" fn(i32) -> !`
found `unsafe extern "C" fn(i32)`
= help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "exit")]`, or `#[link_name = "exit"]`
= note: `#[deny(invalid_runtime_symbol_definitions)]` on by default
error: aborting due to 1 previous error; 2 warnings emitted
Compiler returned: 1
It might be suspicious, but it is not invalid definitely.
Meta
I hit this bug in CO2 which is basically a C frontend for rustc. I would like to enable this very useful lint at least warn by default, but I don't want to annoy C people by forcing them to add __atribute__((no_return)) to their void exit(int); declarations. I expect c2rust to have a similar problem.
cc @Urgau #155521
I tried this code:
I expected to see this happen: Compilation succeed and program returned 5
Instead, this happened:
It might be suspicious, but it is not invalid definitely.
Meta
I hit this bug in CO2 which is basically a C frontend for rustc. I would like to enable this very useful lint at least warn by default, but I don't want to annoy C people by forcing them to add
__atribute__((no_return))to theirvoid exit(int);declarations. I expect c2rust to have a similar problem.cc @Urgau #155521