Skip to content

ICE on no_mangle. #22651

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

Closed
adambirtles opened this issue Feb 22, 2015 · 6 comments
Closed

ICE on no_mangle. #22651

adambirtles opened this issue Feb 22, 2015 · 6 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@adambirtles
Copy link

rustc seems to panic whenever I compile this code:

#![feature(no_std)]
#![feature(lang_items)]

#![no_std]

#[lang = "phantom_fn"]
trait PhantomFn<A: ?Sized, R: ?Sized = ()> { }

#[lang = "sized"]
trait Sized: PhantomFn<Self> { }

#[lang = "copy"]
trait Copy: PhantomFn<Self> { }

#[lang = "sync"]
trait Sync: PhantomFn<Self> { }

#[no_mangle]
pub fn main() {
}

I expected to see the code compile neatly (as it did when I tried yesterday) but this is what I got:

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.
Abort trap: 6

Meta

rustc --version --verbose:

rustc 1.0.0-nightly (522d09dfe 2015-02-19) (built 2015-02-20)
binary: rustc
commit-hash: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
commit-date: 2015-02-19
build-date: 2015-02-20
host: x86_64-apple-darwin
release: 1.0.0-nightly

Backtrace:

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.
Abort trap: 6
@mahkoh
Copy link
Contributor

mahkoh commented Feb 22, 2015

Dup #18358

@kmcallister kmcallister added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 22, 2015
@nagisa
Copy link
Member

nagisa commented Feb 22, 2015

Alternatively dup of #19495, though the assertion differs.

@adambirtles
Copy link
Author

The different assertion may be an OS thing, this is what I get from playpen:

rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/include/llvm/Support/Casting.h:237: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::Function; Y = llvm::Value; typename llvm::cast_retty<X, Y*>::ret_type = llvm::Function*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
Aborted (core dumped)
playpen: application terminated with error code 134
Program ended.

@adambirtles
Copy link
Author

Does anyone know of a workaround for this?

@adambirtles adambirtles changed the title rustc panicking on simple no_std code. ICE on no_mangle. Mar 1, 2015
@nagisa
Copy link
Member

nagisa commented Mar 1, 2015

Do not #[no_mangle] the main. Use #[main] (to define C-like entry) and #[start] (to define barebones entry) attributes instead. Alternatively you can avoid using attributes completely for fn main.

@nagisa
Copy link
Member

nagisa commented Apr 13, 2015

The sample in the report now results in

test.rs:19:1: 20:2 error: entry symbol `main` defined multiple times
test.rs:19 pub fn main() {
test.rs:20 }
help: did you use #[no_mangle] on `fn main`? Use #[start] instead
error: aborting due to previous error

So this can be closed.

@jdm jdm closed this as completed Apr 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants