Skip to content

segfault in peek_loop_context #3969

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
fn main() {
    [(); {
        while true {
            break 9;
        }
        51
    }];
}

original:

// Regression test for issue #114529
// Tests that we do not ICE during const eval for a
// break-with-value in contexts where it is illegal

#[allow(while_true)]
fn main() {
    [(); {
        while true {
            break 9; //~ ERROR `break` with value from a `while` loop
        };
        51
    }];

    [(); {
        while true {
            break 9; //~ ERROR `break` with value from a `while` loop
        };
        51
    }];

    while true {
        break (|| { // Regression test for issue #114529
            let while_true = 9;
        });
    }
}

Version information:

5dc8c4d

Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use

Program output

/tmp/icemaker_global_tempdir.8jWjPQk6ZqHZ/rustc_testrunner_tmpdir_reporting.5nwy1u3Ti7vh/mvce.rs:4:13: error: can only ‘break’ with a value inside a ‘loop’ block [E0571]
    4 |             break 9;
      |             ^~~~~
crab1: internal compiler error: Segmentation fault
0x2fecaf8 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:517
0x196d57f crash_signal
	../../gcc/toplev.cc:321
0x11609c7 Rust::Compile::Context::peek_loop_context()
	../../gcc/rust/backend/rust-compile-context.h:321
0x11609c7 Rust::Compile::CompileExpr::visit(Rust::HIR::BreakExpr&)
	../../gcc/rust/backend/rust-compile-expr.cc:792
0x1162c76 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-expr.cc:48
0x1159890 ???
	../../gcc/rust/backend/rust-compile-stmt.h:33
0x1159b7c Rust::Compile::CompileStmt::Compile(Rust::HIR::Stmt*, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-stmt.cc:36
0x1170dcb Rust::Compile::CompileBlock::visit(Rust::HIR::BlockExpr&)
	../../gcc/rust/backend/rust-compile-block.cc:54
0x11712ee Rust::Compile::CompileBlock::compile(Rust::HIR::BlockExpr&, Rust::Compile::Context*, Bvariable*)
	../../gcc/rust/backend/rust-compile-block.cc:35
0x1160eec Rust::Compile::CompileExpr::visit(Rust::HIR::WhileLoopExpr&)
	../../gcc/rust/backend/rust-compile-expr.cc:774
0x1162c76 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-expr.cc:48
0x1159890 ???
	../../gcc/rust/backend/rust-compile-stmt.h:33
0x1159b7c Rust::Compile::CompileStmt::Compile(Rust::HIR::Stmt*, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-stmt.cc:36
0x118a9fc Rust::Compile::HIRCompileBase::compile_function_body(tree_node*, Rust::HIR::BlockExpr&, Rust::TyTy::BaseType*)
	../../gcc/rust/backend/rust-compile-base.cc:613
0x118eb94 Rust::Compile::HIRCompileBase::compile_constant_item(unsigned int, Rust::TyTy::BaseType*, Rust::TyTy::BaseType*, Rust::Resolver::CanonicalPath const&, Rust::HIR::Expr&, unsigned long, unsigned long)
	../../gcc/rust/backend/rust-compile-base.cc:865
0x118f044 Rust::Compile::HIRCompileBase::compile_constant_expr(Rust::Compile::Context*, unsigned int, Rust::TyTy::BaseType*, Rust::TyTy::BaseType*, Rust::Resolver::CanonicalPath const&, Rust::HIR::Expr&, unsigned long, unsigned long)
	../../gcc/rust/backend/rust-compile-base.cc:573
0x118f044 Rust::Compile::HIRCompileBase::query_compile_const_expr(Rust::Compile::Context*, Rust::TyTy::BaseType*, Rust::HIR::Expr&)
	../../gcc/rust/backend/rust-compile-base.cc:588
0x109f8c0 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::ArrayExpr&)
	../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:1111
0x109a4d4 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
	../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:50
0x10a9acc ???
	../../gcc/rust/typecheck/rust-hir-type-check-stmt.h:33
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions