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

ICE comparing unsized type as raw pointer #18829

Closed
murarth opened this issue Nov 10, 2014 · 5 comments
Closed

ICE comparing unsized type as raw pointer #18829

murarth opened this issue Nov 10, 2014 · 5 comments
Labels
A-DSTs Area: Dynamically-sized types (DSTs) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@murarth
Copy link
Contributor

murarth commented Nov 10, 2014

Attempting to cast &str or a slice to a raw pointer results in a proper error message. Attempting to compare two such invalid casts, however, generates an ICE.
(And I realize now that .as_ptr() is the right way to do what I was trying to do.)

fn main() {
    let a: &[i32] = &[];
    (a as *const _) == (a as *const _);
    ("" as *const _) == ("" as *const _);
}

Results in:

error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' panicked at 'assertion failed: self.appropriate_rvalue_mode(bcx.ccx()) == ByValue', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/librustc/middle/trans/datum.rs:644

stack backtrace:
   1:     0x7f2610acd880 - rt::backtrace::imp::write::h7a90f4ef1aa5a81fsbq
   2:     0x7f2610ad0900 - failure::on_fail::he9ef851a069b43543wq
   3:     0x7f2615036d40 - unwind::begin_unwind_inner::ha2afab22d4dc49ed8Rd
   4:     0x7f261567bb30 - unwind::begin_unwind::h15560861862153460913
   5:     0x7f2615a1eb20 - middle::trans::datum::Datum<K>::to_llscalarish::h5300527991557390520
   6:     0x7f2615a3f650 - middle::trans::expr::trans_binary::h6c193beb06d7e93dcG7
   7:     0x7f2615a34ab0 - middle::trans::expr::trans_unadjusted::h02c4b8f1c6b87a22SZ5
   8:     0x7f26159fbac0 - middle::trans::expr::trans_into::h4971d03ccde714e0Ue5
   9:     0x7f26159faf20 - middle::trans::controlflow::trans_stmt_semi::h8fa1003152ba3849Gu1
  10:     0x7f26159fa4d0 - middle::trans::controlflow::trans_stmt::h98ee011c11c8d6d8tq1
  11:     0x7f26159fbee0 - middle::trans::controlflow::trans_block::h9afd935ec02d5d88zv1
  12:     0x7f2615a9e510 - middle::trans::base::trans_closure::h3e4483ae2d8e884bAGh
  13:     0x7f26159ef140 - middle::trans::base::trans_fn::h7f9774a3926fbf34nSh
  14:     0x7f26159ec9a0 - middle::trans::base::trans_item::h07f36bd67b211f81Bbi
  15:     0x7f2615aa8ce0 - middle::trans::base::trans_crate::hda78095df6dfa8bfC9i
  16:     0x7f2615efa840 - driver::driver::phase_4_translate_to_llvm::h3f7adb4e900158acqyC
  17:     0x7f2615ef16e0 - driver::driver::compile_input::h1c18718eb06a01d2k5B
  18:     0x7f2615f744e0 - driver::run_compiler::hcc1eba405fd576deBVF
  19:     0x7f2615f743d0 - driver::run::closure.146438
  20:     0x7f26156b0c20 - task::TaskBuilder<S>::try_future::closure.104848
  21:     0x7f26156b0a10 - task::TaskBuilder<S>::spawn_internal::closure.104819
  22:     0x7f261537d540 - task::NativeSpawner.Spawner::spawn::closure.8448
  23:     0x7f261508bc50 - rust_try_inner
  24:     0x7f261508bc40 - rust_try
  25:     0x7f26150346c0 - unwind::try::h2eeb8f95c58da3ccQGd
  26:     0x7f2615034550 - task::Task::run::hcb23459dab25134dGMc
  27:     0x7f261537d280 - task::NativeSpawner.Spawner::spawn::closure.8386
  28:     0x7f2615035d60 - thread::thread_start::h033f0420ecdbeed0V7c
  29:     0x7f260fe7d0c0 - start_thread
  30:     0x7f2614cfff89 - __clone
  31:                0x0 - <unknown>
@huonw huonw added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-DSTs Area: Dynamically-sized types (DSTs) labels Nov 12, 2014
@steveklabnik
Copy link
Member

This no longer ICEs for me, and gives the right error:

hello.rs:2:21: 2:23 error: mismatched types:
 expected `&[isize]`,
    found `[_; 0]`
(expected &-ptr,
    found array of 0 elements)

@murarth
Copy link
Contributor Author

murarth commented Jan 16, 2015

@steveklabnik: No, that's just the array [] no longer being implicitly coerced to &[int]. I'm on nightly 2015-01-15 and still get an ICE. I've updated the original comment accordingly. (Added the str case, too.)

@steveklabnik steveklabnik reopened this Jan 16, 2015
@steveklabnik
Copy link
Member

Oops, sorry about that! Re-opened, and your new sample does ICE for me. Thanks!

@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

Still ICEs.

@arielb1
Copy link
Contributor

arielb1 commented Jun 25, 2015

cc rust-lang/rfcs#1135

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) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants