Skip to content

#[lang="exchange_malloc"] seems to be broken #14460

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
snare opened this issue May 27, 2014 · 1 comment
Closed

#[lang="exchange_malloc"] seems to be broken #14460

snare opened this issue May 27, 2014 · 1 comment

Comments

@snare
Copy link

snare commented May 27, 2014

Adding the #[lang="exchange_malloc"] directive to a function causes an assertion failure in the compiler. Tested with the latest version (746d086)

$ cat ex.rs
#![no_std]
#![no_main]

#[no_split_stack]
#[no_mangle]
pub fn thing()->int {
    let y = box 10;
    0
}

#[lang="exchange_malloc"]
pub fn malloc(size: uint) -> *mut u8 {
    0 as *mut u8
}

$ rustc --crate-type=lib ex.rs
ex.rs:7:6: 7:7 warning: unused variable: `y`, #[warn(unused_variable)] on by default
ex.rs:7     let y = box 10;
                ^
ex.rs:12:15: 12:19 warning: unused variable: `size`, #[warn(unused_variable)] on by default
ex.rs:12 pub fn malloc(size: uint) -> *mut u8 {
                       ^~~~
Assertion failed: ((Args.size() == FTy->getNumParams() || (FTy->isVarArg() && Args.size() > FTy->getNumParams())) && "Calling a function with bad signature!"), function init, file /<redacted>/rust/src/llvm/lib/IR/Instructions.cpp, line 276.
zsh: abort      ~/rust/bin/rustc --crate-type=lib ex.rs     zsh: abort      rustc --crate-type=lib ex.rs
@alexcrichton
Copy link
Member

Closing, it was changed recently to take an align parameter as well:

#[lang="exchange_malloc"]
pub fn malloc(size: uint, align: uint) -> *mut u8 { /* ... */ }

Making this a first class error is covered by #9307

bors pushed a commit to rust-lang-ci/rust that referenced this issue Apr 22, 2025
…ust-lang#14460)

changelog: [`cognitive_complexity`]: Consecutive return calls decreased
complexity level of the function by 1.

fixes rust-lang/rust-clippy#14422
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants