Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

[ICE] alignment is calculated incorrectly #401

Open
jyn514 opened this issue May 3, 2020 · 0 comments
Open

[ICE] alignment is calculated incorrectly #401

jyn514 opened this issue May 3, 2020 · 0 comments
Labels
codegen Involves generating Cranelift IR ICE Internal Compiler Error (panic)

Comments

@jyn514
Copy link
Owner

jyn514 commented May 3, 2020

Code

Taken from the gcc torture suite.

union u2 {
    struct {
        int u2s_a, u2s_b, u2s_c;
    } u2_s;
    double u2_d;
} u2a;

union u2 fu2();

void unions() {
    u2a = fu2();
}
The application panicked (crashed).
Message:  `size` is smaller than `dest` and `src`'s alignment value.
Location: /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/cranelift-frontend-0.63.0/src/frontend.rs:632

Expected behavior

This should compile successfully and copy the return value of fu2 into the union.

Note that fixing the alignment will only fix one crash, the other is that we don't implement returning a struct/union from a function.

Backtrace
The application panicked (crashed).
Message:  `size` is smaller than `dest` and `src`'s alignment value.
Location: /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/cranelift-frontend-0.63.0/src/frontend.rs:632

Run with RUST_BACKTRACE=full to include source snippets.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                          (4 post panic frames hidden)                          
 4: cranelift_frontend::frontend::FunctionBuilder::emit_small_memory_copy::hede086de63a955a4
    at /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/cranelift-frontend-0.63.0/src/frontend.rs:632
 5: rcc::ir::expr::<impl rcc::ir::Compiler<B>>::assignment::h2ada95ef31aa5c0b
    at /home/joshua/src/rust/rcc/src/ir/expr.rs:481
 6: rcc::ir::expr::<impl rcc::ir::Compiler<B>>::compile_expr::h2ff96f7396ce7324
    at /home/joshua/src/rust/rcc/src/ir/expr.rs:74
 7: rcc::ir::stmt::<impl rcc::ir::Compiler<B>>::compile_stmt::h7cf294b71e0771d7
    at /home/joshua/src/rust/rcc/src/ir/stmt.rs:41
 8: rcc::ir::stmt::<impl rcc::ir::Compiler<B>>::compile_all::h5bb6ce633e4b1928
    at /home/joshua/src/rust/rcc/src/ir/stmt.rs:19
 9: rcc::ir::Compiler<B>::compile_func::ha6a0196c21c9b041
    at /home/joshua/src/rust/rcc/src/ir/mod.rs:333
10: rcc::ir::compile::hf1c9eb625008fd36
    at /home/joshua/src/rust/rcc/src/ir/mod.rs:112
11: rcc::compile::h54ca7e6b27d0adb9
    at /home/joshua/src/rust/rcc/src/lib.rs:264
12: rcc::aot_main::ha7daa1b1f2888dd2
    at src/main.rs:134
13: rcc::real_main::h8e565e5fa82a899d
    at src/main.rs:122
14: rcc::main::h10b2c818bf9fc3d2
    at src/main.rs:200
                        (12 runtime init frames hidden)  
@jyn514 jyn514 added codegen Involves generating Cranelift IR ICE Internal Compiler Error (panic) labels May 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
codegen Involves generating Cranelift IR ICE Internal Compiler Error (panic)
Projects
None yet
Development

No branches or pull requests

1 participant