Skip to content
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

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants