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

This DST code causes an llvm assertion failure during compilation. #19064

Closed
canndrew opened this issue Nov 18, 2014 · 5 comments
Closed

This DST code causes an llvm assertion failure during compilation. #19064

canndrew opened this issue Nov 18, 2014 · 5 comments
Labels
A-DSTs Area: Dynamically-sized types (DSTs) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@canndrew
Copy link
Contributor

canndrew commented Nov 18, 2014

Trying to build this:

struct Foo(pub str);

impl Foo {
  fn print(&self) {
    match self {
      &Foo(ref s)  => println!("f\"{}\"", s),
    }
  }
}

fn main() {}

and I get this:

rustc: /home/shum/src/rust/rust/src/llvm/include/llvm/Support/Casting.h:237: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::PointerType; Y = const llvm::Type; typename llvm::cast_retty<X, Y*>::ret_type = const llvm::PointerType*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
@steveklabnik steveklabnik added A-DSTs Area: Dynamically-sized types (DSTs) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. labels Jan 29, 2015
bors added a commit that referenced this issue Mar 22, 2015
After this patch code like `let ref a = *"abcdef"` doesn't cause ICE anymore.
Required for #23121

There are still places in rustc_trans where pointers are always assumed to be thin. In particular, #19064 is not resolved by this patch.
@arielb1 arielb1 added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jun 14, 2015
@arielb1
Copy link
Contributor

arielb1 commented Jun 14, 2015

Still crashes in 1.2.0

eefriedman added a commit to eefriedman/rust that referenced this issue Jul 15, 2015
The old code was not well structured, difficult to understand,
and buggy.

The new implementation is completely naive, so there may be a slight
runtime performance loss. That said, adding optimizations on top of
a clear and correct implementation seems easier than trying to
fix the old mess.

Fixes issue rust-lang#19064.
Fixes issue rust-lang#26989.
Fixes issue rust-lang#26251.
Fixes issue rust-lang#18060.
Fixes issue rust-lang#24875.
Fixes issue rust-lang#23311.
Fixes issue rust-lang#20046.
bltavares pushed a commit to bltavares/glacier that referenced this issue Oct 24, 2015
@DanielKeep
Copy link
Contributor

Still happening in 1.7.0 nightly as of now. I believe I've managed to reduce it further to the following; changing [()] out for a non-DST type (like u8) causes the failure to go away, as does removing the &ref. Also, thanks to niconii.

day9asplode.rs:

fn main() { if let Some(&ref _x) = Some::<&[()]>(&[]) {} }
[master] > rustc -vV
rustc 1.7.0-nightly (110df043b 2015-12-13)
binary: rustc
commit-hash: 110df043bf585e94764e07700576200290709859
commit-date: 2015-12-13
host: i686-pc-windows-gnu
release: 1.7.0-nightly
[master] > rustc .\src\bin\day9asplode.rs
Assertion failed!

Program: C:\Users\drk\AppData\Local\.multirust\toolchains\nightly\bin\rustc.exe File: C:/bot/slave/nightly-dist-rustc-win-gnu-32/build/src/llvm/include/llvm/Support/Casting.h, Line 237

Expression: isa<X>(Val) && "cast<Ty>() argument of incompatible type!"

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

@apasel422
Copy link
Contributor

Triage: Still an issue.

@jonas-schievink
Copy link
Contributor

Compiles fine with -Zorbit

@steveklabnik
Copy link
Member

This no longer ICEs as of rustc 1.11.0-nightly (0554abac6 2016-06-10).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-DSTs Area: Dynamically-sized types (DSTs) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

6 participants