Rust-GCC / Rust-GCC/gccrs

NR2: ICE: in operator->, at rust/util/optional.h:1265

Open
#3,629 1 comment 0 reactions 1 assignee View on GitHub

@powerboat9 is already working on this.

Since Mar 31, 2025.

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

Description

auto-reduced (treereduce-rust):

//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use -frust-name-resolution-2.0
fn main() {
    let mut p = Point { x: 3, y: 4 };

    p.x = 5;
    q.x;
}

original:

#!/usr/bin/env run-cargo-script

// check-pass
#![allow(unused_variables)]


fn main() {
    let mut p = Point {x: 3, y: 4};
    let q = &p;

    // This assignment is illegal because the field x is not
    // inherently mutable; since `p` was made immutable, `p.x` is now
    // immutable.  Otherwise the type of &_q.x (&isize) would be wrong.
    p.x = 5; //~ ERROR cannot assign to `p.x` because it is borrowed
    q.x;
}

Version information:

765121736dfe3f5b319bbe9837880deda326394e

Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/765121736dfe3f5b319bbe9837880deda326394e/gcc/rust/util/optional.h#L1259-L1271

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

Program output

crab1: internal compiler error: in operator->, at rust/util/optional.h:1265
0x867b11 tl::optional<Rust::Resolver2_0::Rib::Definition>::operator->()
	../../gcc/rust/util/optional.h:1265
0x867b11 Rust::Resolver2_0::Late::visit(Rust::AST::StructExprStructFields&)
	../../gcc/rust/resolve/rust-late-name-resolver-2.0.cc:434
0xe2faaf void Rust::AST::DefaultASTVisitor::visit<Rust::AST::Expr>(Rust::AST::Expr&)
	../../gcc/rust/ast/rust-ast-visitor.h:402
0xe2faaf Rust::Resolver2_0::Late::visit(Rust::AST::LetStmt&)
	../../gcc/rust/resolve/rust-late-name-resolver-2.0.cc:140
0xc1bdff void Rust::AST::DefaultASTVisitor::visit<Rust::AST::Stmt>(std::unique_ptr<Rust::AST::Stmt, std::default_delete<Rust::AST::Stmt> >&)
	../../gcc/rust/ast/rust-ast-visitor.h:406
0xc1bdff Rust::AST::DefaultASTVisitor::visit(Rust::AST::BlockExpr&)
	../../gcc/rust/ast/rust-ast-visitor.cc:452
0xe0d5d3 std::function<void ()>::operator()() const
	/usr/include/c++/14.2.1/bits/std_function.h:591
0xe0d5d3 Rust::Resolver2_0::NameResolutionContext::scoped(Rust::Resolver2_0::Rib::Kind, unsigned int, std::function<void ()>, tl::optional<Rust::Identifier>)
	../../gcc/rust/resolve/rust-name-resolution-context.cc:122
0xe1130d Rust::Resolver2_0::DefaultResolver::visit(Rust::AST::BlockExpr&)
	../../gcc/rust/resolve/rust-default-resolver.cc:35
0xe0d5d3 std::function<void ()>::operator()() const
	/usr/include/c++/14.2.1/bits/std_function.h:591
0xe0d5d3 Rust::Resolver2_0::NameResolutionContext::scoped(Rust::Resolver2_0::Rib::Kind, unsigned int, std::function<void ()>, tl::optional<Rust::Identifier>)
	../../gcc/rust/resolve/rust-name-resolution-context.cc:122
0xe113f3 Rust::Resolver2_0::DefaultResolver::visit(Rust::AST::Function&)
	../../gcc/rust/resolve/rust-default-resolver.cc:53
0xe32e5f Rust::Resolver2_0::Late::go(Rust::AST::Crate&)
	../../gcc/rust/resolve/rust-late-name-resolver-2.0.cc:118
0xc5c1f2 Rust::Session::compile_crate(char const*)
	../../gcc/rust/rust-session-manager.cc:648
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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.