Rust-GCC / Rust-GCC/gccrs

ICE `in compile_byte_string_literal, at rust/backend/rust-compile-expr.cc:` const array byte lit

Open
#3,934 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
2.9k
Forks
230
Avg merge
19h 55m
Merged PRs (30d)
67

Description

snippet:

//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
const B: [(); b"a"] = [()];

Version information:

5c3e2adc695b04a199d37cacd8c23b14fdab914f

Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/5c3e2adc695b04a199d37cacd8c23b14fdab914f/gcc/rust/backend/rust-compile-expr.cc#L1771-L1783

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

Program output

/tmp/icemaker_global_tempdir.Fy56Vc2ryEMt/rustc_testrunner_tmpdir_reporting.VrD5rGEFpmUa/mvce.rs:1:15: error: mismatched types, expected ‘usize’ but got ‘& [u8; 1]’ [E0308]
    1 | const B: [(); b"a"] = [()];
      |               ^
crab1: internal compiler error: in compile_byte_string_literal, at rust/backend/rust-compile-expr.cc:1777
0x2fec938 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:517
0xc0dfbb fancy_abort(char const*, int, char const*)
	../../gcc/diagnostic.cc:1803
0x90a361 Rust::Compile::CompileExpr::compile_byte_string_literal(Rust::HIR::LiteralExpr const&, Rust::TyTy::BaseType const*)
	../../gcc/rust/backend/rust-compile-expr.cc:1777
0x1164324 ???
	../../gcc/rust/backend/rust-compile-expr.h:38
0x1162ab6 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-expr.cc:48
0x118e72f 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:869
0x118ee84 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
0x118ee84 Rust::Compile::HIRCompileBase::query_compile_const_expr(Rust::Compile::Context*, Rust::TyTy::BaseType*, Rust::HIR::Expr&)
	../../gcc/rust/backend/rust-compile-base.cc:588
0x10831bc Rust::Resolver::TypeCheckType::visit(Rust::HIR::ArrayType&)
	../../gcc/rust/typecheck/rust-hir-type-check-type.cc:717
0x10823f7 Rust::Resolver::TypeCheckType::Resolve(Rust::HIR::Type&)
	../../gcc/rust/typecheck/rust-hir-type-check-type.cc:71
0x1083837 Rust::Resolver::TypeCheckType::Resolve(Rust::HIR::Type&)
	../../gcc/rust/typecheck/rust-hir-type-check-type.cc:67
0x106d4d4 Rust::Resolver::TypeCheckItem::visit(Rust::HIR::ConstantItem&)
	../../gcc/rust/typecheck/rust-hir-type-check-item.cc:492
0x106e105 Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
	../../gcc/rust/typecheck/rust-hir-type-check-item.cc:59
0x100ad4b Rust::Resolver::TypeResolution::Resolve(Rust::HIR::Crate&)
	../../gcc/rust/typecheck/rust-hir-type-check.cc:74
0xdb9778 Rust::Session::compile_crate(char const*)
	../../gcc/rust/rust-session-manager.cc:685
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the ICE with the provided Rust snippet and compiler command. Start in gcc/rust/backend/rust-compile-expr.cc at compile_byte_string_literal, especially lines 1771–1783, and follow the call stack into constant and array-type compilation. Done means this invalid input no longer triggers an internal compiler error and reports the type problem normally.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.