Rust-GCC / Rust-GCC/gccrs

ICE: tree check: expected tree that contains ‘decl common’ structure, have ‘error_mark’ in setup_abi_options, at rust/backend/rust-compile-base.cc:452

Open
#3,668 0 comments 0 reactions 1 assignee View on GitHub

@philberty is already working on this.

Since Apr 29, 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
struct A {
    x: C,
    y: A,
}

#[repr(C)]
struct C {
    x: i32,
}

extern "C" {
    fn foo(x: A);

}

original:

#![deny(improper_ctypes)]
#![allow(dead_code)]

struct A {
    x: C,
    y: A
}

#[repr(C, packed)]
struct B {
    x: i32,
    y: C
}

#[repr(C)]
struct C {
    x: i32
}

type A2 = A;
type B2 = B;
type C2 = C;

#[repr(packed)]
struct D {
    x: C,
    y: A
}

extern "C" {
    fn foo(x: A); //~ ERROR type `A`, which is not FFI-safe
    fn bar(x: A2); //~ ERROR type `A`
    fn improper_ctypes(x: C);
    fn qux(x: A2); //~ ERROR type `A`
    fn quux(x: B2); //~ ERROR type `A`
    fn corge(x: C2);
    fn fred(x: D); //~ ERROR type `A`
}

fn main() { }

Version information:

765121736dfe3f5b319bbe9837880deda326394e

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

Program output

crab1: internal compiler error: tree check: expected tree that contains ‘decl common’ structure, have ‘error_mark’ in setup_abi_options, at rust/backend/rust-compile-base.cc:452
0x9f521f tree_contains_struct_check_failed(tree_node const*, tree_node_structure_enum, char const*, int, char const*)
	../../gcc/tree.cc:9129
0x89bbd3 contains_struct_check(tree_node*, tree_node_structure_enum, char const*, int, char const*)
	../../gcc/tree.h:3758
0x89bbd3 Rust::Compile::HIRCompileBase::setup_abi_options(tree_node*, Rust::ABI)
	../../gcc/rust/backend/rust-compile-base.cc:452
0xd035ee Rust::Compile::CompileExternItem::visit(Rust::HIR::ExternalFunctionItem&)
	../../gcc/rust/backend/rust-compile-extern.h:148
0x10668c6 Rust::Compile::CompileExternItem::compile(Rust::HIR::ExternalItem*, Rust::Compile::Context*, Rust::TyTy::BaseType*, bool, unsigned int)
	../../gcc/rust/backend/rust-compile-extern.h:41
0x10668c6 Rust::Compile::CompileItem::visit(Rust::HIR::ExternBlock&)
	../../gcc/rust/backend/rust-compile-item.cc:288
0xcf15f4 Rust::Compile::CompileItem::compile(Rust::HIR::Item*, Rust::Compile::Context*, Rust::TyTy::BaseType*, unsigned int)
	../../gcc/rust/backend/rust-compile-item.h:37
0xcf15f4 Rust::Compile::CompileCrate::go()
	../../gcc/rust/backend/rust-compile.cc:48
0xcf16db Rust::Compile::CompileCrate::Compile(Rust::HIR::Crate&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile.cc:41
0xce90eb 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.

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.