Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Compile error (vector sorting) #25768

Closed
ghost opened this issue May 25, 2015 · 4 comments
Closed

Compile error (vector sorting) #25768

ghost opened this issue May 25, 2015 · 4 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@ghost
Copy link

ghost commented May 25, 2015

Taken from (https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports):

I tried to compile code to sort a vector. Instead, it gave me a compile error.

I tried this code:

fn main() {
    let new_map: *mut Vec<*const str> = &mut Vec::new();

    unsafe {
        (*new_map).sort_by(|a, b| a.cmp(b));
    }
}

I expected to see this happen: Compile a program to sort a vector

Instead, this happened: Compile error

Meta

rustc --version --verbose:

rustc 1.0.0 (a59de37 2015-05-13) (built 2015-05-14)
binary: rustc
commit-hash: a59de37
commit-date: 2015-05-13
build-date: 2015-05-14
host: x86_64-apple-darwin
release: 1.0.0

Backtrace:

error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with RUST_BACKTRACE=1 for a backtrace
thread 'rustc' panicked at 'assertion failed: self.appropriate_rvalue_mode(bcx.ccx()) == ByValue', /Users/rustbuild/src/rust-buildbot/slave/stable-dist-rustc-mac/build/src/librustc_trans/trans/datum.rs:646

stack backtrace:

   1:        0x106a9ce7f - sys::backtrace::write::h7807ec07859fb503t1r
   2:        0x106aa54b2 - panicking::on_panic::ha0ed2b9b562a7f9ctZv
   3:        0x106a61e35 - rt::unwind::begin_unwind_inner::hbfb8d99cb52be7a1cHv
   4:        0x103abbb1f - rt::unwind::begin_unwind::h17573835868208297571
   5:        0x103b5267d - trans::datum::Datum<'tcx, K>::to_llscalarish::h18059270282086316317
   6:        0x103bda787 - trans::expr::trans_binary::h94d14ab3c2c14ea7O6B
   7:        0x103bd0a32 - trans::expr::trans_unadjusted::h263ec47f91647a4d9zA
   8:        0x103ba4ae7 - trans::expr::trans_into::hbb46bcc22ed210c3X6z
   9:        0x103b241b9 - trans::controlflow::trans_block::hdf65bd89d5d3fafb02u
  10:        0x103b22b55 - trans::base::trans_closure::h41cb738fdafdcb78LCh
  11:        0x103b247ee - trans::base::trans_fn::hbccbee21cfd23d2atNh
  12:        0x103b66c65 - trans::monomorphize::monomorphic_fn::hb0b9d13fdbb393b9tCJ
  13:        0x103b56537 - trans::callee::trans_fn_ref_with_substs::h65df1c1a3f07d589UEn
  14:        0x103b556bd - trans::meth::trans_static_method_callee::h59b2a8c075f63013DEI
  15:        0x103b51f52 - trans::callee::trans::hf3e13a5b6c64ff57jin
  16:        0x103b6786d - trans::callee::trans_call_inner::h8933410478418265344
  17:        0x103bd244f - trans::expr::trans_rvalue_dps_unadjusted::hb679c5947dd23995C5A
  18:        0x103ba4ac7 - trans::expr::trans_into::hbb46bcc22ed210c3X6z
  19:        0x103b241b9 - trans::controlflow::trans_block::hdf65bd89d5d3fafb02u
  20:        0x103b22b55 - trans::base::trans_closure::h41cb738fdafdcb78LCh
  21:        0x103b247ee - trans::base::trans_fn::hbccbee21cfd23d2atNh
  22:        0x103b66c65 - trans::monomorphize::monomorphic_fn::hb0b9d13fdbb393b9tCJ
  23:        0x103b56537 - trans::callee::trans_fn_ref_with_substs::h65df1c1a3f07d589UEn
  24:        0x103b6c861 - trans::meth::trans_method_callee::ha28edc2f1b2a8fd0uzI
  25:        0x103bdf155 - trans::expr::trans_overloaded_op::ha6335bd9494cd525tcC
  26:        0x103bd16d6 - trans::expr::trans_rvalue_dps_unadjusted::hb679c5947dd23995C5A
  27:        0x103bd0864 - trans::expr::trans_unadjusted::h263ec47f91647a4d9zA
  28:        0x103b0266f - trans::expr::trans::h1978f8d98b53e4e9gdA
  29:        0x103bd25dd - trans::expr::trans_rvalue_dps_unadjusted::hb679c5947dd23995C5A
  30:        0x103ba4ac7 - trans::expr::trans_into::hbb46bcc22ed210c3X6z
  31:        0x103b241b9 - trans::controlflow::trans_block::hdf65bd89d5d3fafb02u
  32:        0x103b22b55 - trans::base::trans_closure::h41cb738fdafdcb78LCh
  33:        0x103b247ee - trans::base::trans_fn::hbccbee21cfd23d2atNh
  34:        0x103b66c65 - trans::monomorphize::monomorphic_fn::hb0b9d13fdbb393b9tCJ
  35:        0x103b56537 - trans::callee::trans_fn_ref_with_substs::h65df1c1a3f07d589UEn
  36:        0x103b6c861 - trans::meth::trans_method_callee::ha28edc2f1b2a8fd0uzI
  37:        0x103b6951c - trans::callee::trans_call_inner::h14698893033598190724
  38:        0x103bd25b9 - trans::expr::trans_rvalue_dps_unadjusted::hb679c5947dd23995C5A
  39:        0x103ba4ac7 - trans::expr::trans_into::hbb46bcc22ed210c3X6z
  40:        0x103b241b9 - trans::controlflow::trans_block::hdf65bd89d5d3fafb02u
  41:        0x103b22b55 - trans::base::trans_closure::h41cb738fdafdcb78LCh
  42:        0x103b75504 - trans::closure::trans_closure_expr::h48c9ea863bfedc25Qwq
  43:        0x103bd4013 - trans::expr::trans_rvalue_dps_unadjusted::hb679c5947dd23995C5A
  44:        0x103bd099d - trans::expr::trans_unadjusted::h263ec47f91647a4d9zA
  45:        0x103b0266f - trans::expr::trans::h1978f8d98b53e4e9gdA
  46:        0x103b61eac - trans::callee::trans_args::h7d23e9d4c5491efcHko
  47:        0x103b6a4f6 - trans::callee::trans_call_inner::h14698893033598190724
  48:        0x103bd25b9 - trans::expr::trans_rvalue_dps_unadjusted::hb679c5947dd23995C5A
  49:        0x103ba4ac7 - trans::expr::trans_into::hbb46bcc22ed210c3X6z
  50:        0x103ba45b1 - trans::controlflow::trans_stmt_semi::h9f4c7751e520c73141u
  51:        0x103b23e78 - trans::controlflow::trans_block::hdf65bd89d5d3fafb02u
  52:        0x103bd19bc - trans::expr::trans_rvalue_dps_unadjusted::hb679c5947dd23995C5A
  53:        0x103ba4ac7 - trans::expr::trans_into::hbb46bcc22ed210c3X6z
  54:        0x103b241b9 - trans::controlflow::trans_block::hdf65bd89d5d3fafb02u
  55:        0x103b22b55 - trans::base::trans_closure::h41cb738fdafdcb78LCh
  56:        0x103b247ee - trans::base::trans_fn::hbccbee21cfd23d2atNh
  57:        0x103b27d58 - trans::base::trans_item::hae807f8e0cfc6665Fbi
  58:        0x103b36ba2 - trans::base::trans_crate::h2f3789dec4e60e5cF0i
  59:        0x1035c727e - driver::phase_4_translate_to_llvm::h561d8971e5091942hOa
  60:        0x10359f204 - driver::compile_input::hf0607b3d1fd498bcQba
  61:        0x1036675a3 - run_compiler::he7a5311c755081d7z4b
  62:        0x1036650ca - boxed::F.FnBox<A>::call_box::h5234503372052129763
  63:        0x103664567 - rt::unwind::try::try_fn::h4031265711883657142
  64:        0x106b26508 - rust_try_inner
  65:        0x106b264f5 - rust_try
  66:        0x103664840 - boxed::F.FnBox<A>::call_box::h1044299548107784679
  67:        0x106aa3ffd - sys::thread::create::thread_start::ha3be9b31a8775143L4u
  68:     0x7fff8d73e267 - _pthread_body
  69:     0x7fff8d73e1e4 - _pthread_start
@ghost ghost changed the title Compile error Compile error (vector sorting) May 25, 2015
@shepmaster
Copy link
Member

Smaller example:

fn main() {
    let mut new_map: Vec<*const str> = Vec::new();
    new_map.sort();
}

For anyone who stumbles on this bug, this is not the normal way of sorting strings. As far as I can determine, *const str isn't a valid concept. It never occurs in the Rust source code, except for tests that ensure it is invalid.

@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label May 25, 2015
@mitaa
Copy link
Contributor

mitaa commented May 26, 2015

This triggers the ICE

fn main() {
    let y: *const str = "";
    y == y;
}

Apparently raw fat pointers exist, therefore I think *const str should be fine.
size_of::<*const str>() == 16

@mitaa
Copy link
Contributor

mitaa commented Sep 8, 2015

This compiles now since a implementation of RFC1135 has been merged.

@bluss
Copy link
Member

bluss commented Sep 8, 2015

The tests in #28270 cover this, so we can close this as fixed! (by @arielb1)

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

No branches or pull requests

4 participants