-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Using #![no_main], and a #[no_mange] pub static main array the linker will assume that the main array is actually the main function and execute whatever is in there. Outside of a warning for nonstandard naming this compiles fine on stable and nightly on both debug and release mode.
This example will print the text Main is usually a function\n on x64 linux and probably crash violently on anything else.
It's rather hard to trigger this behavior without trying, but it should probably not compile without errors. Maybe add a check for #![no_main] crates that whatever's declared as #[no_mangle] main is actually a function with the correct signature.
Meta
The issue exists on rustc 1.25.0-nightly, rustc 1.23.0 and anything in between.
icefoxen, jonas-schievink, oli-obk, ExpHP, hanna-kruppe and 7 more
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.