[Bug c++/68220] New: [5.2.1 Regression] Devirtualization ICE in record_target_from_binfo, at ipa-devirt.c:2389

sebastien.piat at epita dot fr gcc-bugzilla@gcc.gnu.org
Thu Nov 5 15:12:00 GMT 2015


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

            Bug ID: 68220
           Summary: [5.2.1 Regression] Devirtualization ICE in
                    record_target_from_binfo, at ipa-devirt.c:2389
           Product: gcc
           Version: 5.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sebastien.piat at epita dot fr
  Target Milestone: ---

Created attachment 36653
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36653&action=edit
The preprocessed file.

The following piece of code causes an internal compiler error when compiled
with this command line : `g++-5 -O3 -std=c++11 ice.cc`.
With this version of g++-5 : Debian 5.2.1-21 and boost version 1.58.
I could not find any simpler way to cause this error, as removing any of the
elements of the given code solves the problem (even using symbol instead of
boost::variant<symbol>).
Note that it works if compiled with optimization up to -O2 or with the flag
`-fno-devirtualize`.

The code:

#include <boost/variant/variant.hpp>

struct symbol
{
  virtual ~symbol();
};

using Identifier = boost::variant<symbol>;

struct Fragment
{
  virtual void foo() const = 0;
  virtual ~Fragment();
};

struct ProcFrag : Fragment
{
  ~ProcFrag() {}
  virtual void foo() const override;
  Identifier id;
};

struct Fragments
{
  ~Fragments()
  {
    delete x;
  }
  Fragment* x;
};

Fragments fragments;

Fragment::~Fragment()
{}

The compilation output with `-v -save-temps` (I have attached the preprocessed
file):

Using built-in specs.
COLLECT_GCC=g++-5
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 5.2.1-21'
--with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-5 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 5.2.1 20151003 (Debian 5.2.1-21) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O3' '-std=c++11' '-Wall' '-Werror'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/5/cc1plus -E -quiet -v -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE ice.cc -mtune=generic -march=x86-64 -std=c++11
-Wall -Werror -O3 -fpch-preprocess -o ice.ii
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/5"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/5
 /usr/include/x86_64-linux-gnu/c++/5
 /usr/include/c++/5/backward
 /usr/lib/gcc/x86_64-linux-gnu/5/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O3' '-std=c++11' '-Wall' '-Werror'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/5/cc1plus -fpreprocessed ice.ii -quiet -dumpbase
ice.cc -mtune=generic -march=x86-64 -auxbase ice -O3 -Wall -Werror -std=c++11
-version -o ice.s
GNU C++11 (Debian 5.2.1-21) version 5.2.1 20151003 (x86_64-linux-gnu)
        compiled by GNU C version 5.2.1 20151003, GMP version 6.0.0, MPFR
version 3.1.3, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++11 (Debian 5.2.1-21) version 5.2.1 20151003 (x86_64-linux-gnu)
        compiled by GNU C version 5.2.1 20151003, GMP version 6.0.0, MPFR
version 3.1.3, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 60de134094777aef87cb5f2c7eb1a063
ice.cc:35:2: internal compiler error: in record_target_from_binfo, at
ipa-devirt.c:2389
 {}
  ^
0x9264f0 record_target_from_binfo
        ../../src/gcc/ipa-devirt.c:2389
0x92616a record_target_from_binfo
        ../../src/gcc/ipa-devirt.c:2430
0x926894 possible_polymorphic_call_targets_1
        ../../src/gcc/ipa-devirt.c:2477
0x927187 possible_polymorphic_call_targets(tree_node*, long,
ipa_polymorphic_call_context, bool*, void**, bool)
        ../../src/gcc/ipa-devirt.c:3006
0x9281fc try_speculative_devirtualization(tree_node*, long,
ipa_polymorphic_call_context)
        ../../src/gcc/ipa-devirt.c:3367
0xfd4d2f ipa_get_indirect_edge_target_1
        ../../src/gcc/ipa-cp.c:2047
0x933ea4 estimate_edge_devirt_benefit
        ../../src/gcc/ipa-inline-analysis.c:3070
0x93422b estimate_edge_size_and_time
        ../../src/gcc/ipa-inline-analysis.c:3110
0x93422b estimate_calls_size_and_time
        ../../src/gcc/ipa-inline-analysis.c:3186
0x9344db estimate_node_size_and_time
        ../../src/gcc/ipa-inline-analysis.c:3281
0x9346e9 estimate_ipcp_clone_size_and_time(cgraph_node*, vec<tree_node*,
va_heap, vl_ptr>, vec<ipa_polymorphic_call_context, va_heap, vl_ptr>,
vec<ipa_agg_jump_function*, va_heap, vl_ptr>, int*, int*, int*)
        ../../src/gcc/ipa-inline-analysis.c:3321
0xfdb824 perform_estimation_of_a_value
        ../../src/gcc/ipa-cp.c:2361
0xfdc7fc estimate_local_effects
        ../../src/gcc/ipa-cp.c:2513
0xfdc7fc propagate_constants_topo
        ../../src/gcc/ipa-cp.c:2726
0xfdc7fc ipcp_propagate_stage
        ../../src/gcc/ipa-cp.c:2827
0xfdd98e ipcp_driver
        ../../src/gcc/ipa-cp.c:4487
0xfdd98e execute
        ../../src/gcc/ipa-cp.c:4582
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.


More information about the Gcc-bugs mailing list