Skip to content

ICE when declaring static char inside a function #7740

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
chris-morgan opened this issue Jul 12, 2013 · 2 comments
Closed

ICE when declaring static char inside a function #7740

chris-morgan opened this issue Jul 12, 2013 · 2 comments
Labels
A-lifetimes Area: Lifetimes / regions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@chris-morgan
Copy link
Member

Minimal test case:

fn main() {
    static A: &'static char = &'A';
}

Also tried a couple of other types; crashes with a u8, doesn't crash with a str.

$ RUST_LOG=rustc=1,::rt::backtrace rustc bad.rs
rust: task failed at 'No enclosing scope for id 7', /home/chris/vc/rust/src/librustc/middle/region.rs:121
/home/chris/opt/rust/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x4b)[0x7fa7f8d9076b]
/home/chris/opt/rust/bin/../lib/librustrt.so(+0x2c0c9)[0x7fa7f8da20c9]
/home/chris/opt/rust/bin/../lib/librustrt.so(upcall_fail+0x1a8)[0x7fa7f8d927b8]
/home/chris/opt/rust/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so(_ZN3sys13begin_unwind_16_89e154cd091567114_0$x2e8$x2dpreE+0x59b)[0x7fa7fa8e22db]
/home/chris/opt/rust/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so(+0x11dd32)[0x7fa7fa8e1d32]
/home/chris/opt/rust/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so(+0x11dc61)[0x7fa7fa8e1c61]
/home/chris/opt/rust/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so(+0x11dcec)[0x7fa7fa8e1cec]
/home/chris/opt/rust/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so(+0x11dc61)[0x7fa7fa8e1c61]
/home/chris/opt/rust/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so(_ZN3sys14__extensions__10meth_109519fail_with17_d96679812a86c36714_0$x2e8$x2dpreE+0x7b)[0x7fa7fa838fbb]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(_ZN6middle6region14__extensions__10meth_7153210encl_scope16_07d3310c43b907714_0$x2e8$x2dpreE+0xcf)[0x7fa7f95c08af]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x6314eb)[0x7fa7f95f84eb]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(_ZN6middle18mem_categorization14__extensions__10meth_7377119cat_expr_unadjusted17_683e145e9333e52a14_0$x2e8$x2dpreE+0xb6c)[0x7fa7f95f702c]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(_ZN6middle18mem_categorization14__extensions__10meth_737698cat_expr17_683e145e9333e52a14_0$x2e8$x2dpreE+0x16b)[0x7fa7f95f639b]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(_ZN6middle18mem_categorization8cat_expr17_8bc74df1a33e285114_0$x2e8$x2dpreE+0x5b)[0x7fa7f95ef9fb]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(_ZN6middle8borrowck14__extensions__10meth_713678cat_expr17_683e145e9333e52a14_0$x2e8$x2dpreE+0x47)[0x7fa7f95baeb7]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(_ZN6middle8borrowck12gather_loans20gather_loans_in_expr17_9ac743166529fa5c14_0$x2e8$x2dpreE+0x1d07)[0x7fa7f95b7bf7]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x1c9819)[0x7fa7f9190819]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x1c958a)[0x7fa7f919058a]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x1cd5c6)[0x7fa7f91945c6]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x1cbc50)[0x7fa7f9192c50]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(_ZN6middle8borrowck12gather_loans15add_stmt_to_map16_e77dfbedc63106514_0$x2e8$x2dpreE+0x12a)[0x7fa7f95b9bba]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x1bdfed)[0x7fa7f9184fed]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(_ZN6middle8borrowck12gather_loans21gather_loans_in_block17_b194266daf4fe94614_0$x2e8$x2dpreE+0xf5)[0x7fa7f95b93f5]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(_ZN6middle8borrowck12gather_loans12gather_loans17_d9b64e693c94523614_0$x2e8$x2dpreE+0x4ee)[0x7fa7f95b1afe]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(_ZN6middle8borrowck11borrowck_fn17_a5de7b93bc5f209c14_0$x2e8$x2dpreE+0x178)[0x7fa7f95e3388]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x1c9970)[0x7fa7f9190970]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x1c958a)[0x7fa7f919058a]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x1c8865)[0x7fa7f918f865]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x1c85f5)[0x7fa7f918f5f5]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x5b23d4)[0x7fa7f95793d4]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(_ZN6middle8borrowck11check_crate17_23db9f9f8380cf2d14_0$x2e8$x2dpreE+0x4da)[0x7fa7f95df58a]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x815ad1)[0x7fa7f97dcad1]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(_ZN6driver6driver12compile_rest16_a7f24595f9c1d7f14_0$x2e8$x2dpreE+0x1e1b)[0x7fa7f97d9c0b]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x84e3b4)[0x7fa7f98153b4]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(_ZN6driver6driver12compile_upto17_ac70fe6818e1c68914_0$x2e8$x2dpreE+0x13c)[0x7fa7f97dd0bc]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(_ZN6driver6driver13compile_input16_a54eace447e7c4014_0$x2e8$x2dpreE+0xd5)[0x7fa7f97dd455]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(_ZN12run_compiler17_e4c098586c60ab4f14_0$x2e8$x2dpreE+0x18e9)[0x7fa7f97fd1a9]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x84e0de)[0x7fa7f98150de]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x84ace1)[0x7fa7f9811ce1]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x84044b)[0x7fa7f980744b]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x84e3b4)[0x7fa7f98153b4]
/home/chris/opt/rust/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so(+0xebbb9)[0x7fa7fa8afbb9]
/home/chris/opt/rust/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so(+0x18ea8c)[0x7fa7fa952a8c]
/home/chris/opt/rust/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x2b)[0x7fa7f8d910fb]
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=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /home/chris/vc/rust/src/librustc/rustc.rs:355
/home/chris/opt/rust/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x4b)[0x7fa7f8d9076b]
/home/chris/opt/rust/bin/../lib/librustrt.so(+0x2c0c9)[0x7fa7f8da20c9]
/home/chris/opt/rust/bin/../lib/librustrt.so(upcall_fail+0x1a8)[0x7fa7f8d927b8]
/home/chris/opt/rust/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so(_ZN3sys13begin_unwind_16_89e154cd091567114_0$x2e8$x2dpreE+0x59b)[0x7fa7fa8e22db]
/home/chris/opt/rust/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so(+0x11e422)[0x7fa7fa8e2422]
/home/chris/opt/rust/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so(+0x11dc61)[0x7fa7fa8e1c61]
/home/chris/opt/rust/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so(+0x11e3dc)[0x7fa7fa8e23dc]
/home/chris/opt/rust/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so(+0x11dc61)[0x7fa7fa8e1c61]
/home/chris/opt/rust/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so(+0x8ba84)[0x7fa7fa84fa84]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(_ZN7monitor17_1ce38b927b935cbd14_0$x2e8$x2dpreE+0x2af5)[0x7fa7f9800825]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(+0x84e3b4)[0x7fa7f98153b4]
/home/chris/opt/rust/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so(_ZN4main15_f3d16eaf7d573814_0$x2e8$x2dpreE+0x69)[0x7fa7f9815009]
/home/chris/opt/rust/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x2b)[0x7fa7f8d910fb]
rust: domain main @0x160fd70 root task failed
@pnkfelix
Copy link
Member

pnkfelix commented Sep 4, 2013

visiting for bug triage, 2013-09-02.

I know some labels to add here. And I'll poke at it a bit too, see if I can dissect a little about the caller (mem_categorization.rs) and why it isn't doing whatever it usually does to deal with the static lifetime.

@pnkfelix
Copy link
Member

pnkfelix commented Sep 4, 2013

By the way, here is one way to work-around this:

pub fn f() {
    static A_backing: char = 'A';   // <---- this is the important thing.
    static A: &'static char = &A_backing;
}

fn main() {
    f();
}

So, next steps for the bug itself:

  1. Obviously we need to deal with the ICE
  2. But also, we need to decide whether the original program is legal. It is conceptually taking the address of the result of evaluating const-expr. That doesn't seem like any big intellectual hurdle, at least for a non-mut static borrow. (I do wonder whether there is any overlap between this and our need to define what const-exprs actually are in the first place.)

pnkfelix added a commit to pnkfelix/rust that referenced this issue Sep 5, 2013
bors added a commit that referenced this issue Sep 5, 2013
…during-gather-loans-of-block, r=nikomatsakis

Fix #7740

r? anyone, @nikomatsakis especially.
flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 21, 2021
…r=llogiq

Refactor `clippy::match_ref_pats` to check for multiple reference patterns

fixes rust-lang#7740

When there is only one pattern, to begin with, i.e. a single deref(`&`), then in such cases we suppress `clippy::match_ref_pats`.
This is done by checking the count of the reference pattern and emitting `clippy::match_ref_pats` when more than one pattern is present.

Removed certain errors in the `stderr` tests as they would not be triggered.

changelog: Refactor `clippy::match_ref_pats` to check for multiple reference patterns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions 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.

2 participants