Rust-GCC / Rust-GCC/gccrs

ICE in non_zero_size_type, at rust/rust-gcc.cc:1895

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

Nobody has claimed this yet.

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

Description

auto-reduced (treereduce-rust):

#[repr(C)]
union U {
    data: (),
}

extern "C" {
    static FOREIGN1: U; // OK

}

original:

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

#[repr(C)]
union U {
    data: (),
}

union W {
    a: u8,
}

extern "C" {
    static FOREIGN1: U; // OK
    static FOREIGN2: W; //~ ERROR `extern` block uses type `W`
}

fn main() {}

Version information:

34b0a681598d52de442a0a21c3a7df20bf1485bc

Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/34b0a681598d52de442a0a21c3a7df20bf1485bc/gcc/rust/rust-gcc.cc#L1889-L1901

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 non_zero_size_type, at rust/rust-gcc.cc:1895
0x8602fa Backend::non_zero_size_type(tree_node*)
	../../gcc/rust/rust-gcc.cc:1895
0xb44bc7 Backend::global_variable(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, tree_node*, bool, bool, bool, unsigned int)
	../../gcc/rust/rust-gcc.cc:1947
0xc75605 Rust::Compile::CompileExternItem::visit(Rust::HIR::ExternalStaticItem&)
	../../gcc/rust/backend/rust-compile-extern.h:75
0xfd63c6 Rust::Compile::CompileExternItem::compile(Rust::HIR::ExternalItem*, Rust::Compile::Context*, Rust::TyTy::BaseType*, bool, unsigned int)
	../../gcc/rust/backend/rust-compile-extern.h:41
0xfd63c6 Rust::Compile::CompileItem::visit(Rust::HIR::ExternBlock&)
	../../gcc/rust/backend/rust-compile-item.cc:288
0xc64994 Rust::Compile::CompileItem::compile(Rust::HIR::Item*, Rust::Compile::Context*, Rust::TyTy::BaseType*, unsigned int)
	../../gcc/rust/backend/rust-compile-item.h:37
0xc64994 Rust::Compile::CompileCrate::go()
	../../gcc/rust/backend/rust-compile.cc:48
0xc64a7b Rust::Compile::CompileCrate::Compile(Rust::HIR::Crate&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile.cc:41
0xc5c48b 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.

Research direction

Reproduce the reduced Rust case with the command in the issue, then inspect non_zero_size_type and global_variable in rust/rust-gcc.cc around lines 1889-1901, along with CompileExternItem in rust/backend/rust-compile-extern.h. Done means the reduced case no longer triggers an internal compiler error and the original extern-static case reports the expected improper_ctypes error for W.

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
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.