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

LLVM failure "Calling a function with a bad signature!" when matching on &'static strs #11940

Closed
netvl opened this issue Jan 30, 2014 · 3 comments · Fixed by #14752
Closed

LLVM failure "Calling a function with a bad signature!" when matching on &'static strs #11940

netvl opened this issue Jan 30, 2014 · 3 comments · Fixed by #14752

Comments

@netvl
Copy link
Contributor

netvl commented Jan 30, 2014

This code:

static TEST_STR: &'static str = "abcd";

fn main() {
    let s = "abcd";
    match s {
        TEST_STR => println!("OK"),
        _ => println!("Nope")
    }
}

crashes rustc with the following error message:

rustc: /home/dpx-infinity/dev/lang/rust/sources/rust/src/llvm/lib/IR/Instructions.cpp:281: void llvm::CallInst::init(llvm::Value*, llvm::ArrayRef<llvm::Value*>, const llvm::Twine&): Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"' failed.
zsh: abort (core dumped)  rustc main.rs

If I remove the first match arm, the program compiles correctly.

I was able to reproduce this only with &'static str constants. Other types of constants I have used seem to work fine.

This happens on Rust 0.9. I cannot check it on master version because I can't compile it for some reason.

@lilyball
Copy link
Contributor

Compiling with a build of rust from yesterday (056363f 2014-01-29 22:21:29 -0800) I get a different error:

Call parameter type does not match function signature!
{ i8*, i64 } { i8* getelementptr inbounds ([5 x i8]* @str1404, i32 0, i32 0), i64 4 }
 %str_slice*  %2 = call i8 @_ZN3str8eq_slice19h4530a4c9ec196a94aT4v0.0E(%str_slice* %s, { i8*, i64 } { i8* getelementptr inbounds ([5 x i8]* @str1404, i32 0, i32 0), i64 4 })
Broken module found, compilation aborted!

@netvl
Copy link
Contributor Author

netvl commented Jan 30, 2014

@kballard, I was just editing the issue to add a note that I'm using Rust 0.9 because for some reason I can't build the compiler from master.

@jfager
Copy link
Contributor

jfager commented Apr 19, 2014

I got bit by this today with a master build (c7553ea Sat Apr 19 02:11:30 2014 -0700):

$ rustc teststrmatch.rs 
Assertion failed: ((i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"), function init, file /Users/jason/src/rust/src/llvm/lib/IR/Instructions.cpp, line 281.
Abort trap: 6

If you replace the static variable with its string literal things work again

fn main() {
    let s = "abcd";
    match s {
        "abcd" => println!("OK"),
        _ => println!("Nope")
    }
}

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

Successfully merging a pull request may close this issue.

3 participants