Skip to content

ICE: translating unsupported cast: *mut [u32] (cast_other) -> *mut c_void (cast_pointer) #23237

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
strega-nil opened this issue Mar 9, 2015 · 7 comments · Fixed by #25038
Closed
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@strega-nil
Copy link
Contributor

error: internal compiler error: translating unsupported cast: *mut [u32] (cast_other) -> *mut libc::types::common::c95::c_void (cast_pointer)
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 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:189

stack backtrace:
   1:     0x7f58387ff2f2 - sys::backtrace::write::hd861c9cad5664affQBA
   2:     0x7f5838825342 - panicking::on_panic::h2d36a117ae395cb9jHJ
   3:     0x7f583876ba89 - rt::unwind::begin_unwind_inner::h020c424433824dc2mnJ
   4:     0x7f5835d790ed - rt::unwind::begin_unwind::h10233696008248825440
   5:     0x7f5835d79925 - diagnostic::Handler::bug::h5b4a3d5d737e3662KdE
   6:     0x7f5836782d2b - session::Session::bug::hc4ea5c682d373bb1tYp
   7:     0x7f5837ef9cde - trans::expr::trans_imm_cast::hcd3ecb042c0927e9bTj
   8:     0x7f5837ee637c - trans::expr::trans_unadjusted::h98b3a24d34abc9f436h
   9:     0x7f5837ea80e0 - trans::expr::trans::h66ceb310b9edf1f9bwh
  10:     0x7f5837ed986b - trans::callee::trans_args::hf2cfa069a4970bdbG3g
  11:     0x7f5837edee74 - trans::callee::trans_call_inner::h17056753389190948462
  12:     0x7f5837ee8077 - trans::expr::trans_rvalue_dps_unadjusted::hbd2cd1fd54de27cayCi
  13:     0x7f5837ea6bd6 - trans::expr::trans_into::hf1ef6b0748ac8f9eTph
  14:     0x7f5837ea5f5e - trans::controlflow::trans_stmt_semi::h91aecc9fc3a8807dI6d
  15:     0x7f5837ea762d - trans::controlflow::trans_block::h47e6e8902755cf9cv7d
  16:     0x7f5837ee768a - trans::expr::trans_rvalue_dps_unadjusted::hbd2cd1fd54de27cayCi
  17:     0x7f5837ea6bd6 - trans::expr::trans_into::hf1ef6b0748ac8f9eTph
  18:     0x7f5837ea7987 - trans::controlflow::trans_block::h47e6e8902755cf9cv7d
  19:     0x7f5837f62ed0 - trans::base::trans_closure::h70b835bf44b08f62ent
  20:     0x7f5837e96f4b - trans::base::trans_fn::h88672d255f7695867xt
  21:     0x7f5837e9809d - trans::monomorphize::monomorphic_fn::h5456f629cfa11f62Oud
  22:     0x7f5837eb86e7 - trans::glue::trans_struct_drop::hca0bf2ab407ff704XKe
  23:     0x7f5837eb60c8 - trans::glue::trans_struct_drop_flag::hd2fdfa898dbd0abe5Ie
  24:     0x7f5837eaf229 - trans::glue::get_drop_glue::h995ee19a14e101b31De
  25:     0x7f5837eae72d - trans::glue::drop_ty::h5b7f57924de7b3bdvAe
  26:     0x7f5837fd1819 - trans::cleanup::DropValue<'tcx>.Cleanup<'tcx>::trans::h050e22dd6399d306nXK
  27:     0x7f5837ebfe1e - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::pop_and_trans_custom_cleanup_scope::h4f8733d43bdc3f3cR0J
  28:     0x7f5837f7daa5 - trans::_match::trans_match_inner::hafede36b631dfe103Kw
  29:     0x7f5837ee7659 - trans::expr::trans_rvalue_dps_unadjusted::hbd2cd1fd54de27cayCi
  30:     0x7f5837ea6bd6 - trans::expr::trans_into::hf1ef6b0748ac8f9eTph
  31:     0x7f5837f92b2e - trans::_match::mk_binding_alloca::h6781106208550372573
  32:     0x7f5837ea60ad - trans::base::init_local::h6b5a17c439dc15bfGBs
  33:     0x7f5837ea7662 - trans::controlflow::trans_block::h47e6e8902755cf9cv7d
  34:     0x7f5837f62ed0 - trans::base::trans_closure::h70b835bf44b08f62ent
  35:     0x7f5837e96f4b - trans::base::trans_fn::h88672d255f7695867xt
  36:     0x7f5837e93819 - trans::base::trans_item::h1cf2dcffa3cf86bfZVt
  37:     0x7f5837f6967c - trans::base::trans_crate::h88960ef764a955bcaSu
  38:     0x7f5838e23f92 - driver::phase_4_translate_to_llvm::h5d3ca9bd44c7f33agOa
  39:     0x7f5838dff8ea - driver::compile_input::h124aae68147ae8b8Nba
  40:     0x7f5838ec415d - run_compiler::hffd5283ae5d6d3abG6b
  41:     0x7f5838ec1ecc - thunk::F.Invoke<A, R>::invoke::h16438916220137010031
  42:     0x7f5838ec0b20 - rt::unwind::try::try_fn::h17325604874211535233
  43:     0x7f5838891118 - rust_try_inner
  44:     0x7f5838891105 - rust_try
  45:     0x7f5838ec12ab - thunk::F.Invoke<A, R>::invoke::h5807416775295653773
  46:     0x7f5838812b45 - sys::thread::thread_start::h2188587ec04914c6t8E
  47:     0x7f583285d181 - start_thread
  48:     0x7f58383e447c - __clone
  49:                0x0 - <unknown>

Could not compile `handmade_libsdl`.

To learn more, run the command again with --verbose.

This is done when compiling this repository. Use cargo build on either the entire handmade_hero crate, or handmade_libsdl. Warning: Ugly, no_std code ahead!

Cleaned up repo: newrepo

It does need to be across crate lines, and needs to be returned in a result, afaict.

rustc 1.0.0-nightly (91bdf23f5 2015-03-09) (built 2015-03-09)

@strega-nil
Copy link
Contributor Author

The issue is that I should not be able to write *self.data as *mut c_void because self.data is a [T].

Same with #23240.

@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 10, 2015
@strega-nil
Copy link
Contributor Author

Actually, to that end, why is *mut [T] bigger than a *mut anything? Why is a *mut a fat pointer at all?

@jdm
Copy link
Contributor

jdm commented Mar 10, 2015

Very similar to #22554, #21397, #19424.

@strega-nil
Copy link
Contributor Author

@jdm Yes it is, pretty much the same. A *const [x] should not be differently sized from a *const y, at least IMHO, so why is it?

@huonw
Copy link
Member

huonw commented Mar 10, 2015

*const X is a &X with fewer guarantees; one can convert between them freely (if you ensure the guarantees are maintained for *const X -> &X). In particular, this means *const [T] is a fat pointer to match &[T].

@strega-nil
Copy link
Contributor Author

That is weird...

@strega-nil
Copy link
Contributor Author

NVM, I now understand why it is a fat pointer. However, this should be an easy fix, right? Why is a *mut [T] seen as the same size as a *mut T in rustc?

Well, now it isn't, so #23240 is fixed, but it still panics at translating unsupported cast.

bluss pushed a commit to bluss/rust that referenced this issue May 1, 2015
Fixes ICEs where non-fat pointers and scalars are cast to fat pointers,

Fixes rust-lang#21397
Fixes rust-lang#22955
Fixes rust-lang#23237
Fixes rust-lang#24100
bors added a commit that referenced this issue May 2, 2015
typeck: Make sure casts from other types to fat pointers are illegal

Fixes ICEs where non-fat pointers and scalars are cast to fat pointers,

Fixes #21397
Fixes #22955
Fixes #23237
Fixes #24100
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

Successfully merging a pull request may close this issue.

3 participants