Skip to content

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

Closed
@netvl

Description

@netvl

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions