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

            Bug ID: 126268
           Summary: internal compiler error: in
                    possible_polymorphic_call_targets, at
                    ipa-devirt.cc:3325
           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
$ gcc -O2 bug.cpp
during IPA pass: inline
/tmp/bug.cpp:14:1: internal compiler error: in
possible_polymorphic_call_targets, at ipa-devirt.cc:3325
   14 | }
      | ^
0x2a71f7b internal_error(char const*, ...)
        /home/user/software/gcc/slot-b/src/gcc/diagnostic-global-context.cc:787
0xad2239 fancy_abort(char const*, int, char const*)
        /home/user/software/gcc/slot-b/src/gcc/diagnostics/context.cc:1813
0x912572 possible_polymorphic_call_targets(tree_node*, long,
ipa_polymorphic_call_context, bool*, void**, bool)
        /home/user/software/gcc/slot-b/src/gcc/ipa-devirt.cc:3325
0x283d6cf ipa_get_indirect_edge_target_1
        /home/user/software/gcc/slot-b/src/gcc/ipa-cp.cc:3279
0x283f39c ipa_get_indirect_edge_target(cgraph_edge*, ipa_call_arg_values*,
bool*)
        /home/user/software/gcc/slot-b/src/gcc/ipa-cp.cc:3329
0x1228a6c estimate_edge_devirt_benefit
        /home/user/software/gcc/slot-b/src/gcc/ipa-fnsummary.cc:3575
0x122c19e estimate_edge_size_and_time
        /home/user/software/gcc/slot-b/src/gcc/ipa-fnsummary.cc:3626
0x122c19e estimate_calls_size_and_time_1
        /home/user/software/gcc/slot-b/src/gcc/ipa-fnsummary.cc:3688
0x1230b04 ipa_call_context::estimate_size_and_time(ipa_call_estimates*, bool,
bool)
        /home/user/software/gcc/slot-b/src/gcc/ipa-fnsummary.cc:4132
0x12454e1 do_estimate_edge_time(cgraph_edge*, sreal*)
        /home/user/software/gcc/slot-b/src/gcc/ipa-inline-analysis.cc:233
0x1245b68 do_estimate_edge_size(cgraph_edge*)
        /home/user/software/gcc/slot-b/src/gcc/ipa-inline-analysis.cc:326
0x124749d estimate_edge_size(cgraph_edge*)
        /home/user/software/gcc/slot-b/src/gcc/ipa-inline.h:79
0x124749d estimate_edge_growth(cgraph_edge*)
        /home/user/software/gcc/slot-b/src/gcc/ipa-inline.h:100
0x28613c8 want_inline_small_function_p
        /home/user/software/gcc/slot-b/src/gcc/ipa-inline.cc:1023
0x2866d93 inline_small_functions
        /home/user/software/gcc/slot-b/src/gcc/ipa-inline.cc:2196
0x2866d93 ipa_inline
        /home/user/software/gcc/slot-b/src/gcc/ipa-inline.cc:2917
0x2866d93 execute
        /home/user/software/gcc/slot-b/src/gcc/ipa-inline.cc:3440
/home/user/software/gcc/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 -O2 -o
/tmp/cc4uSyOZ.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 bug.cpp
class a {
public:
  virtual void e();
};
class f : public a {};
class g : a {
  long c[1000000000];
};
class h : g, public f {};
void bar(f &b) {
  b.e();
  h d;
  bar(d);
}
```

https://godbolt.org/z/h5n68jdoK

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

I've tested a few versions on compiler explorer and the newest stable one that
did not ICE  I found is 4.9.4 https://godbolt.org/z/1vd7En78a


Preprocessed source:
```cpp
// Target: x86_64-pc-linux-gnu
// Configured with: /home/user/software/gcc/slot-b/src/configure
--prefix=/home/user/software/gcc/slot-b --enable-languages=c,c++
--disable-bootstrap --disable-multilib --with-gmp=/usr --with-mpfr=/usr
--with-mpc=/usr
// Thread model: posix
// Supported LTO compression algorithms: zlib zstd
// gcc version 17.0.0 20260714 (experimental) (GCC)
//
// during IPA pass: inline
// /tmp/bug.cpp:14:1: internal compiler error: in
possible_polymorphic_call_targets, at ipa-devirt.cc:3325
//    14 | }
//       | ^
// 0x2a71f7b internal_error(char const*, ...)
//      /home/user/software/gcc/slot-b/src/gcc/diagnostic-global-context.cc:787
// 0xad2239 fancy_abort(char const*, int, char const*)
//      /home/user/software/gcc/slot-b/src/gcc/diagnostics/context.cc:1813
// 0x912572 possible_polymorphic_call_targets(tree_node*, long,
ipa_polymorphic_call_context, bool*, void**, bool)
//      /home/user/software/gcc/slot-b/src/gcc/ipa-devirt.cc:3325
// 0x283d6cf ipa_get_indirect_edge_target_1
//      /home/user/software/gcc/slot-b/src/gcc/ipa-cp.cc:3279
// 0x283f39c ipa_get_indirect_edge_target(cgraph_edge*, ipa_call_arg_values*,
bool*)
//      /home/user/software/gcc/slot-b/src/gcc/ipa-cp.cc:3329
// 0x1228a6c estimate_edge_devirt_benefit
//      /home/user/software/gcc/slot-b/src/gcc/ipa-fnsummary.cc:3575
// 0x122c19e estimate_edge_size_and_time
//      /home/user/software/gcc/slot-b/src/gcc/ipa-fnsummary.cc:3626
// 0x122c19e estimate_calls_size_and_time_1
//      /home/user/software/gcc/slot-b/src/gcc/ipa-fnsummary.cc:3688
// 0x1230b04 ipa_call_context::estimate_size_and_time(ipa_call_estimates*,
bool, bool)
//      /home/user/software/gcc/slot-b/src/gcc/ipa-fnsummary.cc:4132
// 0x12454e1 do_estimate_edge_time(cgraph_edge*, sreal*)
//      /home/user/software/gcc/slot-b/src/gcc/ipa-inline-analysis.cc:233
// 0x1245b68 do_estimate_edge_size(cgraph_edge*)
//      /home/user/software/gcc/slot-b/src/gcc/ipa-inline-analysis.cc:326
// 0x124749d estimate_edge_size(cgraph_edge*)
//      /home/user/software/gcc/slot-b/src/gcc/ipa-inline.h:79
// 0x124749d estimate_edge_growth(cgraph_edge*)
//      /home/user/software/gcc/slot-b/src/gcc/ipa-inline.h:100
// 0x28613c8 want_inline_small_function_p
//      /home/user/software/gcc/slot-b/src/gcc/ipa-inline.cc:1023
// 0x2866d93 inline_small_functions
//      /home/user/software/gcc/slot-b/src/gcc/ipa-inline.cc:2196
// 0x2866d93 ipa_inline
//      /home/user/software/gcc/slot-b/src/gcc/ipa-inline.cc:2917
// 0x2866d93 execute
//      /home/user/software/gcc/slot-b/src/gcc/ipa-inline.cc:3440
// -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
-O2 -freport-bug -o - -frandom-seed=0 -fdump-noaddr
// Please submit a full bug report, with preprocessed source.
// Please include the complete backtrace with any bug report.
// See <https://gcc.gnu.org/bugs/> for instructions.

//
/home/user/software/gcc/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 -O2
-freport-bug -o - -frandom-seed=0 -fdump-noaddr

# 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"
class a {
public:
  virtual void e();
};
class f : public a {};
class g : a {
  long c[1000000000];
};
class h : g, public f {};
void bar(f &b) {
  b.e();
  h d;
  bar(d);
}
```

Reply via email to