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

internal compiler error: incorrect size #13186

Closed
stepancheg opened this issue Mar 28, 2014 · 4 comments
Closed

internal compiler error: incorrect size #13186

stepancheg opened this issue Mar 28, 2014 · 4 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@stepancheg
Copy link
Contributor

bug.rs:

pub struct Request {
    analyze: Option<int>,
    unknown_command: Option<Option<bool>>,
}

pub fn default_instance() -> &'static Request {
    static instance: Request = Request {
        analyze: None,
        unknown_command: None,
    };
    &'static instance
}

fn main() {}

RUST_BACKTRACE=1 rustc ./bug.rs:

{ { i8, [15 x i8] }, { i8, [2 x i8] } } { { i8, [15 x i8] } { i8 0, [15 x i8] undef }, { i8, [2 x i8] } { i8 0, [2 x i8] undef } }
{ { i8, [7 x i8], [1 x i64] }, { i8, [0 x i8], [2 x i8] } } undef
error: internal compiler error: const expr(27: Request{analyze: None, unknown_command: None,}) of type Request has size 19 instead of 24
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at '~Any', /build/buildd/rust-nightly-201403270405~c83994e~precise/src/libsyntax/diagnostic.rs:123
stack backtrace:
   1:     0x7f25fdd3ad40 - rt::backtrace::imp::write::h6b777dcaf409ea23F2b::v0.10.pre
   2:     0x7f25fdc9c930 - rt::unwind::begin_unwind_inner::h127556ef836f43d59Cb::v0.10.pre
   3:     0x7f25fcf775c0 - <unknown>
   4:     0x7f25fcf781a0 - diagnostic::Handler::bug::h90ba33079579ed8cpVb::v0.10.pre
   5:     0x7f25fe934450 - driver::session::Session::bug::h861141e387b844784gg::v0.10.pre
   6:     0x7f25fe9d5d00 - middle::trans::consts::const_expr::h184e010c42c47b98ASi::v0.10.pre
   7:     0x7f25fe9313c0 - middle::trans::base::get_item_val::h6182c9507a6ad448T4o::v0.10.pre
   8:     0x7f25fe9d7ad0 - middle::trans::consts::trans_const::hb8427f2eaca603fbmGj::v0.10.pre
   9:     0x7f25fe9301b0 - middle::trans::base::trans_item::ha5706cc0fc79239cXKo::v0.10.pre
  10:     0x7f25fe9619f0 - middle::trans::controlflow::trans_stmt::h768eb5d45871275d8Xa::v0.10.pre
  11:     0x7f25fe963570 - middle::trans::controlflow::trans_block::hc51a2a8399fee0bcc2a::v0.10.pre
  12:     0x7f25fea05730 - middle::trans::base::trans_closure::h80d2b66d04a2d7e9yro::v0.10.pre
  13:     0x7f25fe9352d0 - middle::trans::base::trans_fn::h4d00598e72c1fbe7mzo::v0.10.pre
  14:     0x7f25fe9301b0 - middle::trans::base::trans_item::ha5706cc0fc79239cXKo::v0.10.pre
  15:     0x7f25fea0a140 - middle::trans::base::trans_mod::h3b0d6ed6e779ebe82Po::v0.10.pre
  16:     0x7f25fea13600 - middle::trans::base::trans_crate::h0223b28ee84b5a27vmq::v0.10.pre
  17:     0x7f25ff0599d0 - driver::driver::phase_4_translate_to_llvm::h70976aba4cbfb3846Fe::v0.10.pre
  18:     0x7f25ff05bba0 - driver::driver::compile_input::h8b8903fabd6a5683VVe::v0.10.pre
  19:     0x7f25ff07fa80 - run_compiler::h41aecde7ee81abf7cym::v0.10.pre
  20:     0x7f25ff0972d0 - <unknown>
  21:     0x7f25ff095c00 - <unknown>
  22:     0x7f25ff091530 - <unknown>
  23:     0x7f25fe3df590 - <unknown>
  24:     0x7f25fdd361d0 - <unknown>
  25:     0x7f25fdd41810 - rust_try
  26:     0x7f25fdd36010 - rt::task::Task::run::heda54ea5581c3cc41t9::v0.10.pre
  27:     0x7f25fe3df360 - <unknown>
  28:     0x7f25fdd39880 - <unknown>
  29:     0x7f25fb2a4dc0 - start_thread
  30:                0x0 - <unknown>

Using rust nightly, version: 201403270405~c83994e, on Linux x86_64.

@stepancheg
Copy link
Contributor Author

Almost fixed it. Need some time to implement tests.

stepancheg added a commit to stepancheg/rust that referenced this issue Apr 13, 2014
This patch fixes issue rust-lang#13186.

When generating constant expression for enum, it is possible that
alignment of expression may be not equal to alignment of type.  In that
case space after last struct field must be padded to match size of value
and size of struct. This commit adds that padding.

See detailed explanation in src/test/run-pass/trans-tag-static-padding.rs
bors added a commit that referenced this issue May 5, 2014
This patch fixes issue #13186.

When generating constant expression for enum, it is possible that
alignment of expression may be not equal to alignment of type.  In that
case space after last struct field must be padded to match size of value
and size of struct. This commit adds that padding.

See detailed explanation in src/test/run-pass/trans-tag-static-padding.rs
@ghost
Copy link

ghost commented Jun 22, 2014

Looks like it's fixed now?

@stepancheg
Copy link
Contributor Author

@jakub- yes, but repr for packed structs is still broken.

@stepancheg
Copy link
Contributor Author

Closing, because there's separate issue for repr #13486

notriddle pushed a commit to notriddle/rust that referenced this issue Sep 20, 2022
Filter imports on find-all-references

Attempt to rust-lang#13184
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

2 participants