Rust-GCC / Rust-GCC/gccrs

ICE in global_variable_set_init, at rust/rust-gcc.cc:1982

Open
#3,544 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):

fn non_elidable<'a, 'b>(a: &'a u8, b: &'b u8) -> &'a u8 {
    a
}

static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = &(non_elidable as fn(&u8, &u8) -> &u8);

original:

//~^ ERROR missing lifetime specifier [E0106]![allow(dead_code)]

fn non_elidable<'a, 'b>(a: &'a u8, b: &'b u8) -> &'a u8 {
    a
}

// the boundaries of elision
static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 =
//~^ ERROR missing lifetime specifier [E0106]
    &(non_elidable as fn(&u8, &u8) -> &u8);
    //~^ ERROR missing lifetime specifier [E0106]

fn main() {}

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 global_variable_set_init, at rust/rust-gcc.cc:1982
0x8606cf Backend::global_variable_set_init(Bvariable*, tree_node*)
	../../gcc/rust/rust-gcc.cc:1982
0xfd89fd Rust::Compile::CompileItem::visit(Rust::HIR::StaticItem&)
	../../gcc/rust/backend/rust-compile-item.cc:90
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.

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 reduced Rust input and command shown in the issue, then inspect global_variable_set_init at rust/rust-gcc.cc:1982 and its caller in backend/rust-compile-item.cc:90. Trace how the static function pointer is handled, and verify that compiling the input no longer aborts with an internal compiler error.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.