<p dir="auto">Possible (probable) duplicate of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="30426131" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/13186" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/13186/hovercard" href="https://github.com/rust-lang/rust/issues/13186">#13186</a>.</p>
<p dir="auto">Compiling the following program against with rust@30fe550 against <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/brson/rust-sdl/commit/804adf6/hovercard" href="https://github.com/brson/rust-sdl/commit/804adf6">brson/rust-sdl@<tt>804adf6</tt></a>:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="extern crate sdl;

static my_pixfmt: sdl::video::PixelFormat = sdl::video::PixelFormat {
    palette: None,
    bpp: 24,
    r_loss: 0,
    g_loss: 0,
    b_loss: 0,
    a_loss: 0,
    r_shift: 16,
    g_shift: 8,
    b_shift: 0,
    a_shift: 0,
    r_mask: 0xff,
    g_mask: 0xff00,
    b_mask: 0xff0000,
    a_mask: 0,
    color_key: 0,
    alpha: 0,
};

fn main() {
    print!(&quot;{:?}&quot;, my_pixfmt);
}"><pre class="notranslate"><span class="pl-k">extern</span> <span class="pl-k">crate</span> sdl<span class="pl-kos">;</span>

<span class="pl-k">static</span> my_pixfmt<span class="pl-kos">:</span> sdl<span class="pl-kos">::</span>video<span class="pl-kos">::</span><span class="pl-smi">PixelFormat</span> = sdl<span class="pl-kos">::</span>video<span class="pl-kos">::</span><span class="pl-smi">PixelFormat</span> <span class="pl-kos">{</span>
    <span class="pl-c1">palette</span><span class="pl-kos">:</span> <span class="pl-v">None</span><span class="pl-kos">,</span>
    <span class="pl-c1">bpp</span><span class="pl-kos">:</span> <span class="pl-c1">24</span><span class="pl-kos">,</span>
    <span class="pl-c1">r_loss</span><span class="pl-kos">:</span> <span class="pl-c1">0</span><span class="pl-kos">,</span>
    <span class="pl-c1">g_loss</span><span class="pl-kos">:</span> <span class="pl-c1">0</span><span class="pl-kos">,</span>
    <span class="pl-c1">b_loss</span><span class="pl-kos">:</span> <span class="pl-c1">0</span><span class="pl-kos">,</span>
    <span class="pl-c1">a_loss</span><span class="pl-kos">:</span> <span class="pl-c1">0</span><span class="pl-kos">,</span>
    <span class="pl-c1">r_shift</span><span class="pl-kos">:</span> <span class="pl-c1">16</span><span class="pl-kos">,</span>
    <span class="pl-c1">g_shift</span><span class="pl-kos">:</span> <span class="pl-c1">8</span><span class="pl-kos">,</span>
    <span class="pl-c1">b_shift</span><span class="pl-kos">:</span> <span class="pl-c1">0</span><span class="pl-kos">,</span>
    <span class="pl-c1">a_shift</span><span class="pl-kos">:</span> <span class="pl-c1">0</span><span class="pl-kos">,</span>
    <span class="pl-c1">r_mask</span><span class="pl-kos">:</span> <span class="pl-c1">0xff</span><span class="pl-kos">,</span>
    <span class="pl-c1">g_mask</span><span class="pl-kos">:</span> <span class="pl-c1">0xff00</span><span class="pl-kos">,</span>
    <span class="pl-c1">b_mask</span><span class="pl-kos">:</span> <span class="pl-c1">0xff0000</span><span class="pl-kos">,</span>
    <span class="pl-c1">a_mask</span><span class="pl-kos">:</span> <span class="pl-c1">0</span><span class="pl-kos">,</span>
    <span class="pl-c1">color_key</span><span class="pl-kos">:</span> <span class="pl-c1">0</span><span class="pl-kos">,</span>
    <span class="pl-c1">alpha</span><span class="pl-kos">:</span> <span class="pl-c1">0</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-k">fn</span> <span class="pl-en">main</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-en">print</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"{:?}"</span>, my_pixfmt<span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">gives:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ RUST_BACKTRACE=1 rustc -L rust-sdl -o test test.rs
{ { i8, [15 x i8] }, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i8 } { { i8, [15 x i8] } { i8 0, [15 x i8] undef }, i8 24, i8 0, i8 0, i8 0, i8 0, i8 16, i8 8, i8 0, i8 0, i32 255, i32 65280, i32 16711680, i32 0, i32 0, i8 0 }
{ { i8, [7 x i8], [1 x i64] }, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i8 } undef
error: internal compiler error: const expr(8: sdl::video::PixelFormat{palette: None,
                        bpp: 24,
                        r_loss: 0,
                        g_loss: 0,
                        b_loss: 0,
                        a_loss: 0,
                        r_shift: 16,
                        g_shift: 8,
                        b_shift: 0,
                        a_shift: 0,
                        r_mask: 255,
                        g_mask: 65280,
                        b_mask: 16711680,
                        a_mask: 0,
                        color_key: 0,
                        alpha: 0,}) of type sdl::video::PixelFormat has size 52 instead of 56
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', /home/robn/code/rust/rust/src/libsyntax/diagnostic.rs:155
stack backtrace:
   1:     0x7f46a1812930 - rt::backtrace::imp::write::h726c0ee05b0a1251rta::v0.11.pre
   2:     0x7f46a1772370 - rt::unwind::begin_unwind_inner::h9b7e455dab1796daw39::v0.11.pre
   3:     0x7f46a0c39430 - rt::unwind::begin_unwind::h5910056841063238677::v0.11.pre
   4:     0x7f46a0c3a490 - diagnostic::Handler::bug::h0f9bbab1cbb7e822AYb::v0.11.pre
   5:     0x7f46a2429510 - driver::session::Session::bug::h6e55d6e6cbf0d844bhh::v0.11.pre
   6:     0x7f46a24db640 - middle::trans::consts::const_expr::ha281951f96861546GFj::v0.11.pre
   7:     0x7f46a2426850 - middle::trans::base::get_item_val::h4b8a8b57d5346ddbBNp::v0.11.pre
   8:     0x7f46a24dd3c0 - middle::trans::consts::trans_const::h6abb7670a66f1aecstk::v0.11.pre
   9:     0x7f46a2425440 - middle::trans::base::trans_item::h65d6980b59f31439Btp::v0.11.pre
  10:     0x7f46a250d2c0 - middle::trans::base::trans_mod::hdd24677d9163c30cHyp::v0.11.pre
  11:     0x7f46a25151a0 - middle::trans::base::trans_crate::h0920ca7f9115adc25dq::v0.11.pre
  12:     0x7f46a2c404a0 - driver::driver::phase_4_translate_to_llvm::hb81995af2fcfe7361Cf::v0.11.pre
  13:     0x7f46a2c42a90 - driver::driver::compile_input::hfaa2edba3ed249a4QSf::v0.11.pre
  14:     0x7f46a2c67490 - run_compiler::h0c58ff7ffab7f82efpn::v0.11.pre
  15:     0x7f46a2c7f210 - main_args::closure.91455
  16:     0x7f46a2c7d710 - monitor::closure.91330
  17:     0x7f46a2c79000 - task::TaskBuilder::try::closure.91096
  18:     0x7f46a1e9d650 - task::spawn_opts::closure.7103
  19:     0x7f46a180d970 - rt::task::Task::run::closure.39989
  20:     0x7f46a18196b0 - rust_try
  21:     0x7f46a180d7b0 - rt::task::Task::run::hc79a6e8202de0a541T7::v0.11.pre
  22:     0x7f46a1e9d420 - task::spawn_opts::closure.7076
  23:     0x7f46a1811470 - rt::thread::thread_start::h915d8ac90bd84ba1My8::v0.11.pre
  24:     0x7f469f52ffa0 - start_thread
  25:     0x7f46a1445a09 - __clone
  26:                0x0 - &lt;unknown&gt;"><pre class="notranslate"><code class="notranslate">$ RUST_BACKTRACE=1 rustc -L rust-sdl -o test test.rs
{ { i8, [15 x i8] }, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i8 } { { i8, [15 x i8] } { i8 0, [15 x i8] undef }, i8 24, i8 0, i8 0, i8 0, i8 0, i8 16, i8 8, i8 0, i8 0, i32 255, i32 65280, i32 16711680, i32 0, i32 0, i8 0 }
{ { i8, [7 x i8], [1 x i64] }, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i8 } undef
error: internal compiler error: const expr(8: sdl::video::PixelFormat{palette: None,
                        bpp: 24,
                        r_loss: 0,
                        g_loss: 0,
                        b_loss: 0,
                        a_loss: 0,
                        r_shift: 16,
                        g_shift: 8,
                        b_shift: 0,
                        a_shift: 0,
                        r_mask: 255,
                        g_mask: 65280,
                        b_mask: 16711680,
                        a_mask: 0,
                        color_key: 0,
                        alpha: 0,}) of type sdl::video::PixelFormat has size 52 instead of 56
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', /home/robn/code/rust/rust/src/libsyntax/diagnostic.rs:155
stack backtrace:
   1:     0x7f46a1812930 - rt::backtrace::imp::write::h726c0ee05b0a1251rta::v0.11.pre
   2:     0x7f46a1772370 - rt::unwind::begin_unwind_inner::h9b7e455dab1796daw39::v0.11.pre
   3:     0x7f46a0c39430 - rt::unwind::begin_unwind::h5910056841063238677::v0.11.pre
   4:     0x7f46a0c3a490 - diagnostic::Handler::bug::h0f9bbab1cbb7e822AYb::v0.11.pre
   5:     0x7f46a2429510 - driver::session::Session::bug::h6e55d6e6cbf0d844bhh::v0.11.pre
   6:     0x7f46a24db640 - middle::trans::consts::const_expr::ha281951f96861546GFj::v0.11.pre
   7:     0x7f46a2426850 - middle::trans::base::get_item_val::h4b8a8b57d5346ddbBNp::v0.11.pre
   8:     0x7f46a24dd3c0 - middle::trans::consts::trans_const::h6abb7670a66f1aecstk::v0.11.pre
   9:     0x7f46a2425440 - middle::trans::base::trans_item::h65d6980b59f31439Btp::v0.11.pre
  10:     0x7f46a250d2c0 - middle::trans::base::trans_mod::hdd24677d9163c30cHyp::v0.11.pre
  11:     0x7f46a25151a0 - middle::trans::base::trans_crate::h0920ca7f9115adc25dq::v0.11.pre
  12:     0x7f46a2c404a0 - driver::driver::phase_4_translate_to_llvm::hb81995af2fcfe7361Cf::v0.11.pre
  13:     0x7f46a2c42a90 - driver::driver::compile_input::hfaa2edba3ed249a4QSf::v0.11.pre
  14:     0x7f46a2c67490 - run_compiler::h0c58ff7ffab7f82efpn::v0.11.pre
  15:     0x7f46a2c7f210 - main_args::closure.91455
  16:     0x7f46a2c7d710 - monitor::closure.91330
  17:     0x7f46a2c79000 - task::TaskBuilder::try::closure.91096
  18:     0x7f46a1e9d650 - task::spawn_opts::closure.7103
  19:     0x7f46a180d970 - rt::task::Task::run::closure.39989
  20:     0x7f46a18196b0 - rust_try
  21:     0x7f46a180d7b0 - rt::task::Task::run::hc79a6e8202de0a541T7::v0.11.pre
  22:     0x7f46a1e9d420 - task::spawn_opts::closure.7076
  23:     0x7f46a1811470 - rt::thread::thread_start::h915d8ac90bd84ba1My8::v0.11.pre
  24:     0x7f469f52ffa0 - start_thread
  25:     0x7f46a1445a09 - __clone
  26:                0x0 - &lt;unknown&gt;
</code></pre></div>
<p dir="auto">Unfortunately I was unable to reduce this to a case that doesn't require rust-sdl. The PixelFormat structure is a bit too complex for me to know which bits are important for this case.</p>
<p dir="auto">Happy to help reduce it further if I can. Let me know.</p>
<p dir="auto">bug.rs:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pub struct Request {
    analyze: Option&lt;int&gt;,
    unknown_command: Option&lt;Option&lt;bool&gt;&gt;,
}

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

fn main() {}"><pre class="notranslate"><code class="notranslate">pub struct Request {
    analyze: Option&lt;int&gt;,
    unknown_command: Option&lt;Option&lt;bool&gt;&gt;,
}

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

fn main() {}
</code></pre></div>
<p dir="auto">RUST_BACKTRACE=1 rustc ./bug.rs:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{ { 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 - &lt;unknown&gt;
   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 - &lt;unknown&gt;
  21:     0x7f25ff095c00 - &lt;unknown&gt;
  22:     0x7f25ff091530 - &lt;unknown&gt;
  23:     0x7f25fe3df590 - &lt;unknown&gt;
  24:     0x7f25fdd361d0 - &lt;unknown&gt;
  25:     0x7f25fdd41810 - rust_try
  26:     0x7f25fdd36010 - rt::task::Task::run::heda54ea5581c3cc41t9::v0.10.pre
  27:     0x7f25fe3df360 - &lt;unknown&gt;
  28:     0x7f25fdd39880 - &lt;unknown&gt;
  29:     0x7f25fb2a4dc0 - start_thread
  30:                0x0 - &lt;unknown&gt;"><pre class="notranslate"><code class="notranslate">{ { 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 - &lt;unknown&gt;
   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 - &lt;unknown&gt;
  21:     0x7f25ff095c00 - &lt;unknown&gt;
  22:     0x7f25ff091530 - &lt;unknown&gt;
  23:     0x7f25fe3df590 - &lt;unknown&gt;
  24:     0x7f25fdd361d0 - &lt;unknown&gt;
  25:     0x7f25fdd41810 - rust_try
  26:     0x7f25fdd36010 - rt::task::Task::run::heda54ea5581c3cc41t9::v0.10.pre
  27:     0x7f25fe3df360 - &lt;unknown&gt;
  28:     0x7f25fdd39880 - &lt;unknown&gt;
  29:     0x7f25fb2a4dc0 - start_thread
  30:                0x0 - &lt;unknown&gt;
</code></pre></div>
<p dir="auto">Using rust nightly, version: 201403270405~c83994e, on Linux x86_64.</p>