https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85393
Bug ID: 85393 Summary: [8 Regression] Miscompilation with hot/cold partitioning starting with r254832 Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- test.C: #include <stdexcept> #include <vector> void foo (char const *s); struct S { ~S () noexcept (false) { throw std::runtime_error ("foo"); } }; int main(int argc, char *argv[]) { std::vector <std::vector <char>> args; try { { S k; foo ("A"); } if (argv) throw std::runtime_error ("foo"); args.push_back ({}); } catch (std::runtime_error const& e) {} } test2.C: void foo (char const *) {} g++ -g -O2 -o test{,.C,2.C} segfaults because vector dtor is called with NULL this. My bisection points to r254832, Marek's to r250360 (I've used 7.x STL headers, dunno what has Marek used). In any case, the segfault goes away with -fno-reorder-blocks-and-partition, and the only r254832 vs. r254831 differences in *.optimized dump I see are branch probabilities, so it must be RTL optimization related (or target issue).