ICE in eval_component_reference, at rust/backend/rust-constexpr.cc , const casting
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 20h 2m
- Merged PRs (30d)
- 66
Description
auto-reduced (treereduce-rust):
//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use -frust-crate-attr=no_core
const a: &str = "foo";
const b: *const u8 = c as *const u8;
const c: *const str = &a as *const str;
original:
const a: &str = "foo";
const b: *const u8 = c as *const u8; //~ ERROR casting
const c: *const str = &a as *const str; //~ ERROR casting
fn main() {
}
Version information:
c539964b8cc842e871d77b45150df6a5882335fb
Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/c539964b8cc842e871d77b45150df6a5882335fb/gcc/rust/backend/rust-constexpr.cc#L1832-L1844
Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use -frust-crate-attr=no_core -frust-crate-attr=feature(no_core)
Program output
crab1: internal compiler error: in eval_component_reference, at rust/backend/rust-constexpr.cc:1838
0x32edd17 internal_error(char const*, ...)
../../gcc/diagnostic-global-context.cc:787
0xc847b9 fancy_abort(char const*, int, char const*)
../../gcc/diagnostics/context.cc:1813
0x93070f eval_component_reference
../../gcc/rust/backend/rust-constexpr.cc:1838
0x11f6247 eval_constant_expression
../../gcc/rust/backend/rust-constexpr.cc:2419
0x11fc1ff eval_store_expression
../../gcc/rust/backend/rust-constexpr.cc:2743
0x11f4646 eval_constant_expression
../../gcc/rust/backend/rust-constexpr.cc:2254
0x11f557b eval_constant_expression
../../gcc/rust/backend/rust-constexpr.cc:2181
0x11f5955 eval_statement_list
../../gcc/rust/backend/rust-constexpr.cc:4877
0x11f5955 eval_constant_expression
../../gcc/rust/backend/rust-constexpr.cc:2261
0x11f4951 eval_constant_expression
../../gcc/rust/backend/rust-constexpr.cc:2265
0x11f30ed eval_call_expression
../../gcc/rust/backend/rust-constexpr.cc:3762
0x11f4718 eval_constant_expression
../../gcc/rust/backend/rust-constexpr.cc:2175
0x11f77b7 Rust::Compile::fold_expr(tree_node*)
../../gcc/rust/backend/rust-constexpr.cc:618
0x120acac 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:1017
0x11c893a Rust::Compile::CompileItem::visit(Rust::HIR::ConstantItem&)
../../gcc/rust/backend/rust-compile-item.cc:127
0xedd1bb Rust::Compile::CompileItem::compile(Rust::HIR::Item*, Rust::Compile::Context*, Rust::TyTy::BaseType*, unsigned long)
../../gcc/rust/backend/rust-compile-item.h:37
0xedd1bb Rust::Compile::CompileCrate::go()
../../gcc/rust/backend/rust-compile.cc:49
0xedd1bb Rust::Compile::CompileCrate::Compile(Rust::HIR::Crate&, Rust::Compile::Context*)
../../gcc/rust/backend/rust-compile.cc:42
0xecc57a Rust::Session::compile_crate(char const*)
../../gcc/rust/rust-session-manager.cc:855
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 /tmp/icemaker_global_tempdir.fj8QfFurbjWE/rustc_testrunner_tmpdir_reporting.qcqSbraFfXMM/mvce.rs -o/tmp/icemaker_global_tempdir.fj8QfFurbjWE/rustc_testrunner_tmpdir_reporting.qcqSbraFfXMM/binaryname -frust-incomplete-and-experimental-compiler-do-not-use -frust-crate-attr=no_core -frust-crate-attr=feature(no_core)
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reduced Rust reproducer and inspect eval_component_reference in gcc/rust/backend/rust-constexpr.cc around lines 1832-1844. Run the provided crab1 command to reproduce the ICE, then trace the constant-expression evaluation shown in the backtrace. Done means the input no longer aborts in eval_component_reference and the original casting diagnostics are handled without an internal compiler error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100