https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125091

            Bug ID: 125091
           Summary: [17 regression] internal compiler error: in
                    get_partitioning_class, at symtab.cc:2203 with -flto
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lu.maltsis at postgrad dot manchester.ac.uk
  Target Milestone: ---

```sh
$ g++ -flto /tmp/bug.cpp
during IPA pass: modref
/tmp/bug.cpp:8:1: internal compiler error: in get_partitioning_class, at
symtab.cc:2203
    8 | }
      | ^
0x28e52ab internal_error(char const*, ...)
        /home/user/software/g++/slot-b/src/gcc/diagnostic-global-context.cc:787
0xabf92d fancy_abort(char const*, int, char const*)
        /home/user/software/g++/slot-b/src/gcc/diagnostics/context.cc:1813
0x8ab13d symtab_node::get_partitioning_class()
        /home/user/software/g++/slot-b/src/gcc/symtab.cc:2203
0x130d7ff lto_output_varpool_node
        /home/user/software/g++/slot-b/src/gcc/lto-cgraph.cc:648
0x130d7ff output_symtab()
        /home/user/software/g++/slot-b/src/gcc/lto-cgraph.cc:1061
0x1324bd4 lto_output()
        /home/user/software/g++/slot-b/src/gcc/lto-streamer-out.cc:2918
0x13c1738 write_lto
        /home/user/software/g++/slot-b/src/gcc/passes.cc:2793
0x13c1738 ipa_write_summaries_1
        /home/user/software/g++/slot-b/src/gcc/passes.cc:2859
0x13c1738 ipa_write_summaries()
        /home/user/software/g++/slot-b/src/gcc/passes.cc:2919
0xf67acf ipa_passes
        /home/user/software/g++/slot-b/src/gcc/cgraphunit.cc:2292
0xf67acf symbol_table::compile()
        /home/user/software/g++/slot-b/src/gcc/cgraphunit.cc:2367
0xf6a446 symbol_table::compile()
        /home/user/software/g++/slot-b/src/gcc/cgraphunit.cc:2345
0xf6a446 symbol_table::finalize_compilation_unit()
        /home/user/software/g++/slot-b/src/gcc/cgraphunit.cc:2626
/home/user/software/g++/slot-b/libexec/gcc/x86_64-pc-linux-gnu/17.0.0/cc1plus
-quiet -imultiarch x86_64-linux-gnu -D_GNU_SOURCE /tmp/bug.cpp -quiet -dumpdir
a- -dumpbase bug.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -flto -o
/tmp/ccfTL5qQ.s
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.

$ cat /tmp/bug.cpp
struct T {
  int i, x;
}h;
auto [i, j] = h;
void foo() {
  static int &i = j;
  int *w = &i;
}
```

Compiler Explorer Reproducer: https://godbolt.org/z/1xhqTeP3j
Succeeds with -O: https://godbolt.org/z/8hWTev8zx

GCC Commit Hash: c392d64098cc675c804ff4f516548d023a4fe29a
(https://github.com/gcc-mirror/gcc/commit/c392d64098cc675c804ff4f516548d023a4fe29a)

ICE on Assertions trunk 11.1: https://godbolt.org/z/7qWeKzT4s
Succeeds on Assertions Trunk 10.5: https://godbolt.org/z/MKzd95x5W
ICE on Assertions trunk 10.4: https://godbolt.org/z/bqx3Pozro

Please note that -freport-bug I get 
"The bug is not reproducible, so it is likely a hardware or OS problem."
But this also happens on Compiler Explorer: https://godbolt.org/z/rf7E8Gons


Temp generated with -save-temps:
```
$ cat bug.ii
# 0 "/tmp/bug.cpp"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3
# 0 "<command-line>" 2
# 1 "/tmp/bug.cpp"
struct T {
  int i, x;
}h;
auto [i, j] = h;
void foo() {
  static int &i = j;
  int *w = &i;
}
```

This looks similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116526 but
does not require any of the flags except for -flto

Reply via email to