https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70393
Bug ID: 70393 Summary: Miscompilation: missing constructor call for static object Product: gcc Version: 5.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: js at alien8 dot de Target Milestone: --- Created attachment 38078 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38078&action=edit Testcase For the attached testcase, g++ on Linux miscompiles and there is no constructor called for the static object. That results in the vtable being 0 and the program segfaulting. clang compiles this without problem. % g++ --version g++ (GCC) 5.3.1 20151207 (Red Hat 5.3.1-2) Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. To reproduce do the following: % g++ -std=c++11 -o testcase testcase.cpp % ./testcase set_element() on B @ 0x602070 call_element() on B @ 0x602070 zsh: segmentation fault (core dumped) ./testcase Expected output is this: % clang++ -std=c++11 -o testcase testcase.cpp % ./testcase set_element() on B @ 0x602068 call_element() on B @ 0x602068 vfunc() on AB @ 0x602068