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

ICE when compiling vector literal with non-constant length #3645

Closed
Blei opened this issue Oct 3, 2012 · 3 comments
Closed

ICE when compiling vector literal with non-constant length #3645

Blei opened this issue Oct 3, 2012 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-typesystem Area: The type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Milestone

Comments

@Blei
Copy link
Contributor

Blei commented Oct 3, 2012

Compiling the following program leads to an internal compiler error:

fn main(++args: ~[~str]) {
    let n = 1;
    let a = ~[0, ..n];
}

Trace:

tmp % RUST_LOG=rustc=0,::rt::backtrace rustc fail.rs 
rust: task failed at 'Unsupported constant expr', /home/philipp/programming/rust-git/src/rustc/middle/const_eval.rs:351
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x5d)[0x7fd46bbf456d]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustrt.so(+0x31e4d)[0x7fd46bc0be4d]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustrt.so(upcall_fail+0x1a8)[0x7fd46bbf6e68]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustc-c84825241471686d-0.4.so(_ZN6middle10const_eval15eval_const_expr15_052f2a2040b8d23_04E+0x2f2)[0x7fd46c014f22]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustc-c84825241471686d-0.4.so(_ZN6middle2ty17eval_repeat_count16_b613c7e2c7253203_04E+0x60)[0x7fd46c0815f0]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustc-c84825241471686d-0.4.so(+0x3afdec)[0x7fd46c1ebdec]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustc-c84825241471686d-0.4.so(+0x689ff0)[0x7fd46c4c5ff0]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustc-c84825241471686d-0.4.so(+0x3acef9)[0x7fd46c1e8ef9]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustc-c84825241471686d-0.4.so(+0x689ff0)[0x7fd46c4c5ff0]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustc-c84825241471686d-0.4.so(+0x3cac0a)[0x7fd46c206c0a]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustc-c84825241471686d-0.4.so(+0x3cb30e)[0x7fd46c20730e]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustc-c84825241471686d-0.4.so(+0x325cbe)[0x7fd46c161cbe]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustc-c84825241471686d-0.4.so(+0x689ff0)[0x7fd46c4c5ff0]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustc-c84825241471686d-0.4.so(+0x3751f0)[0x7fd46c1b11f0]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustc-c84825241471686d-0.4.so(+0x3738f3)[0x7fd46c1af8f3]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustc-c84825241471686d-0.4.so(+0x37114a)[0x7fd46c1ad14a]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/libsyntax-84efebcb12c867a2-0.4.so(+0xae74d)[0x7fd46c95074d]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/libsyntax-84efebcb12c867a2-0.4.so(+0xae5b4)[0x7fd46c9505b4]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustc-c84825241471686d-0.4.so(_ZN6middle6typeck11check_crate17_f0c9dce01f38a0a13_04E+0xcf6)[0x7fd46c290776]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustc-c84825241471686d-0.4.so(_ZN6driver6driver12compile_upto17_c9ea81e17d7f15573_04E+0x1646)[0x7fd46c49b206]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustc-c84825241471686d-0.4.so(+0x689ff0)[0x7fd46c4c5ff0]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustc-c84825241471686d-0.4.so(_ZN6driver6driver13compile_input16_f2f88af42d830dc3_04E+0xbd)[0x7fd46c49e50d]
rustc[0x408d28]
rustc[0x412084]
rustc[0x40e503]
rustc[0x40d1bc]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/libcore-c3ca5d77d81b46c1-0.4.so(+0x76474)[0x7fd46d243474]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/libcore-c3ca5d77d81b46c1-0.4.so(+0xb7430)[0x7fd46d284430]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x24)[0x7fd46bbf4d14]
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=0,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /home/philipp/programming/rust-git/src/rustc/driver/rustc.rs:275
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x5d)[0x7fd46bbf456d]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustrt.so(+0x31e4d)[0x7fd46bc0be4d]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustrt.so(upcall_fail+0x1a8)[0x7fd46bbf6e68]
rustc(_rust_main+0xbf4)[0x411c54]
rustc[0x412084]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x24)[0x7fd46bbf4d14]
rust: domain main @0x18fb230 root task failed
rust: task failed at 'killed', /home/philipp/programming/rust-git/src/libcore/task.rs:662
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x5d)[0x7fd46bbf456d]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustrt.so(+0x31e4d)[0x7fd46bc0be4d]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustrt.so(upcall_fail+0x1a8)[0x7fd46bbf6e68]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/libcore-c3ca5d77d81b46c1-0.4.so(_ZN4task5yield16_9531951b4f79f8b3_04E+0xbd)[0x7fd46d22c5fd]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/libcore-c3ca5d77d81b46c1-0.4.so(+0x911d6)[0x7fd46d25e1d6]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/libcore-c3ca5d77d81b46c1-0.4.so(_ZN7private11weaken_task16_245c26cb8d7b1343_04E+0xd2)[0x7fd46d25e012]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/libcore-c3ca5d77d81b46c1-0.4.so(+0x90f0b)[0x7fd46d25df0b]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/libcore-c3ca5d77d81b46c1-0.4.so(+0xb7430)[0x7fd46d284430]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/libcore-c3ca5d77d81b46c1-0.4.so(+0x90260)[0x7fd46d25d260]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/libcore-c3ca5d77d81b46c1-0.4.so(+0x8fbfe)[0x7fd46d25cbfe]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/libcore-c3ca5d77d81b46c1-0.4.so(+0x8f266)[0x7fd46d25c266]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/libcore-c3ca5d77d81b46c1-0.4.so(+0x76474)[0x7fd46d243474]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/libcore-c3ca5d77d81b46c1-0.4.so(+0xb7430)[0x7fd46d284430]
/home/philipp/programming/rust-git/x86_64-unknown-linux-gnu/stage2/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x24)[0x7fd46bbf4d14]
@nikomatsakis
Copy link
Contributor

Obviously an ICE is a bug, but there is an interesting question as to
whether this should work or be a static error. Currently, the n in
such an expression is supposed to be a compile-time constant. As a
workaround, you can use vec::from_elem()

@graydon
Copy link
Contributor

graydon commented Oct 3, 2012

Yeah, this is an illegal construct but we should report it more sensibly.

@graydon
Copy link
Contributor

graydon commented Mar 21, 2013

on trunk this reports a clear error about requiring a constant integer and exits cleanly, closing.

@graydon graydon closed this as completed Mar 21, 2013
RalfJung pushed a commit to RalfJung/rust that referenced this issue Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-typesystem Area: The type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants