ICE in compute_address_for_trait_item, at rust/backend/rust-compile.cc:346

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

Nobody has claimed this yet.

Assessment

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

Research direction

Reproduce the ICE with the reduced Rust example and inspect compute_address_for_trait_item at rust/backend/rust-compile.cc:346, using the reported call path through coerce_to_dyn_object and MethodCallExpr. Confirm the compiler handles this trait method case without an internal compiler error, and verify the reduced example compiles successfully afterward.

Written by the indexing model from the issue text.

Description

bug

auto-reduced (treereduce-rust):

trait FontTableTagConversions {
    fn tag_to_string(self);
}

impl FontTableTagConversions for FontTableTagConversions {
    fn tag_to_string(self) {
        5.tag_to_string();
    }
}

original:

// run-pass
#![allow(dead_code)]

type FontTableTag = u32;

trait FontTableTagConversions {
  fn tag_to_string(self);
}

impl FontTableTagConversions for FontTableTagConversions {
  fn tag_to_string(self) {
    5.tag_to_string();
  }
}

pub fn main() {
    5.tag_to_string();
}

Version information:

a988708b4ba2b5a27715ea34c09ccfd3ed5143ca

Command:
crab1 -Warray-bounds -mtune=generic -march=x86-64 -O0 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib64 -frust-incomplete-and-experimental-compiler-do-not-use

Program output

crab1: internal compiler error: in compute_address_for_trait_item, at rust/backend/rust-compile.cc:346
0x863d7f Rust::Compile::HIRCompileBase::compute_address_for_trait_item(Rust::Resolver::TraitItemReference const*, Rust::TyTy::TypeBoundPredicate const*, std::vector<std::pair<Rust::Resolver::TraitReference*, Rust::HIR::ImplBlock*>, std::allocator<std::pair<Rust::Resolver::TraitReference*, Rust::HIR::ImplBlock*> > >&, Rust::TyTy::BaseType const*, Rust::TyTy::BaseType const*, unsigned int)
	../../gcc/rust/backend/rust-compile.cc:346
0xc660f6 Rust::Compile::HIRCompileBase::coerce_to_dyn_object(tree_node*, Rust::TyTy::BaseType const*, Rust::TyTy::DynamicObjectType const*, unsigned int)
	../../gcc/rust/backend/rust-compile.cc:219
0xfe2a40 Rust::Compile::HIRCompileBase::resolve_adjustements(std::vector<Rust::Resolver::Adjustment, std::allocator<Rust::Resolver::Adjustment> >&, tree_node*, unsigned int)
	../../gcc/rust/backend/rust-compile-expr.cc:2030
0xfe4558 Rust::Compile::CompileExpr::visit(Rust::HIR::MethodCallExpr&)
	../../gcc/rust/backend/rust-compile-expr.cc:1433
0xfe0c20 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-expr.cc:47
0xfdb9e0 ???
	../../gcc/rust/backend/rust-compile-stmt.h:33
0xfdbd8d Rust::Compile::CompileStmt::Compile(Rust::HIR::Stmt*, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-stmt.cc:36
0x100c05b Rust::Compile::HIRCompileBase::compile_function_body(tree_node*, Rust::HIR::BlockExpr&, Rust::TyTy::BaseType*)
	../../gcc/rust/backend/rust-compile-base.cc:579
0x100fb8c Rust::Compile::HIRCompileBase::compile_function(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Rust::HIR::SelfParam&, std::vector<Rust::HIR::FunctionParam, std::allocator<Rust::HIR::FunctionParam> >&, Rust::HIR::FunctionQualifiers const&, Rust::HIR::Visibility&, std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >&, unsigned int, Rust::HIR::BlockExpr*, Rust::Resolver::CanonicalPath const&, Rust::TyTy::FnType*)
	../../gcc/rust/backend/rust-compile-base.cc:761
0xfd7c2d Rust::Compile::CompileItem::visit(Rust::HIR::Function&)
	../../gcc/rust/backend/rust-compile-item.cc:256
0xfd5dd7 Rust::Compile::CompileInherentImplItem::Compile(Rust::HIR::ImplItem*, Rust::Compile::Context*, Rust::TyTy::BaseType*, bool, unsigned int)
	../../gcc/rust/backend/rust-compile-implitem.h:37
0xfd5dd7 Rust::Compile::CompileItem::visit(Rust::HIR::ImplBlock&)
	../../gcc/rust/backend/rust-compile-item.cc:280
0xc64954 Rust::Compile::CompileItem::compile(Rust::HIR::Item*, Rust::Compile::Context*, Rust::TyTy::BaseType*, unsigned int)
	../../gcc/rust/backend/rust-compile-item.h:37
0xc64954 Rust::Compile::CompileCrate::go()
	../../gcc/rust/backend/rust-compile.cc:48
0xc64a3b Rust::Compile::CompileCrate::Compile(Rust::HIR::Crate&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile.cc:41
0xc5c44b Rust::Session::compile_crate(char const*)
	../../gcc/rust/rust-session-manager.cc:733
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.

Dominant language
C++
Stars
2.9k
Forks
231
Avg merge
20h 2m
Merged PRs (30d)
66

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.

More from Rust-GCC/gccrs

All issues in Rust-GCC/gccrs

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.