Assertion failed in llvm/include/llvm/Support/Casting.h

384d195
Opened by Carl Lerche at 2023-04-05 17:38:47

Source:

pub extern "C" fn alt_main() {
    extern {
        fn main() -> i32;
    }

    unsafe { main(); }
}

pub fn main() {
    println!("Hello");
}

Result:

$ rustc alt_main.rs -C link-args="-e_alt_main"
Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/llvm/include/llvm/Support/Casting.h, line 237.

Rustc: rustc 1.17.0-nightly (c49d10207 2017-02-07) on OS X

Edit: I'm aware that there are issues w/ the actual code, but even if I fix them, the assertion still fails

  1. This may be related to #59062 and #38641, which have the same error message and also involve extern functions.

    I have a fourth example of code that triggers this assertion failure here:

    https://gist.github.com/rust-play/d065ae0e5e47281564b83390a93f46e8

    Kyle J Strand at 2019-07-06 23:06:37