ICE: `in hash_operand, at fold-const.cc:4013` with -O3 `static mut x: &'static u32 = &1;`
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
auto-reduced (treereduce-rust):
//@compile-flags: -O3 -frust-incomplete-and-experimental-compiler-do-not-use
static mut x: &'static u32 = &1;
original:
// check-pass
#![allow(non_upper_case_globals)]
static mut x: &'static u32 = &1;
fn foo() {
unsafe { x = &0; }
}
fn main() { }
Version information:
5c3e2adc695b04a199d37cacd8c23b14fdab914f
Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/5c3e2adc695b04a199d37cacd8c23b14fdab914f/gcc/fold-const.cc#L4007-L4019
Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -O3 -frust-incomplete-and-experimental-compiler-do-not-use
Program output
Analyzing compilation unit
Performing interprocedural optimizations
<*free_lang_data> {heap 1124k} <visibility> {heap 1124k} <build_ssa_passes> {heap 1124k} <opt_local_passes> {heap 1124k} <remove_symbols> {heap 1124k} <targetclone> {heap 1124k} <free-fnsummary> {heap 1124k}during IPA pass: icf
crab1: internal compiler error: in hash_operand, at fold-const.cc:4013
0x2fec938 internal_error(char const*, ...)
../../gcc/diagnostic-global-context.cc:517
0xc0dfbb fancy_abort(char const*, int, char const*)
../../gcc/diagnostic.cc:1803
0x953a7f operand_compare::hash_operand(tree_node const*, inchash::hash&, unsigned int)
../../gcc/fold-const.cc:4013
0x142f0bb operand_compare::hash_operand(tree_node const*, inchash::hash&, unsigned int)
../../gcc/fold-const.cc:4287
0x2d6a76e ipa_icf::sem_variable::init(ipa_icf_gimple::func_checker*)
../../gcc/ipa-icf.cc:1948
0x2d7d028 ipa_icf::sem_variable::parse(varpool_node*, bitmap_obstack*, ipa_icf_gimple::func_checker*)
../../gcc/ipa-icf.cc:1928
0x2d7d028 ipa_icf::sem_variable::parse(varpool_node*, bitmap_obstack*, ipa_icf_gimple::func_checker*)
../../gcc/ipa-icf.cc:1920
0x2d7d028 ipa_icf::sem_item_optimizer::parse_funcs_and_vars()
../../gcc/ipa-icf.cc:2530
0x17dd05c execute_ipa_summary_passes(ipa_opt_pass_d*)
../../gcc/passes.cc:2299
0x12d9497 ipa_passes
../../gcc/cgraphunit.cc:2253
0x12d9497 symbol_table::compile()
../../gcc/cgraphunit.cc:2351
0x12dc927 symbol_table::compile()
../../gcc/cgraphunit.cc:2329
0x12dc927 symbol_table::finalize_compilation_unit()
../../gcc/cgraphunit.cc:2607
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reduced Rust reproducer in /tmp/im/a.rs and the referenced gcc/fold-const.cc lines 4007-4019. Run gccrs with -O3 and inspect the ipa_icf.cc stack path through sem_variable::init and hash_operand. Done means this input no longer triggers the 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
- 48/100