https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87288
Bug ID: 87288 Summary: Segfault after const_cast with "-O2 -ftree-loop-vectorize" but _without_ "-mavx" Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jorrit at jorrit dot de Target Milestone: --- Created attachment 44682 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44682&action=edit Test case The attached test case segfaults when compiled as /usr/bin/g++-8 -O2 -ftree-loop-vectorize -o test-cornerstoragerefwrap-fail test.ii It exits successfully when compiled with either /usr/bin/g++-8 -O2 -ftree-loop-vectorize -mavx -o test-cornerstoragerefwrap-pass test.ii /usr/bin/g++-8 -O2 -o test-cornerstoragerefwrap-pass test.ii The const_cast in the test case came out of std::array (in the _S_ref() that is called by operator[]). The segfault occurs with - g++-8 (Debian 8.2.0-4) 8.2.0 from Debian buster (registry.dune-project.org/docker/ci/debian:10) - g++ (GCC) 8.1.0 from Coliru (except that I can't test -mavx there), see http://coliru.stacked-crooked.com/a/43b736434d1b2e15 The segfault does not occur with - g++ (GCC) 7.3.0 from gcc:7.3.0 on hub.docker.com - g++ (Debian 6.3.0-18+deb9u1) 6.3.0 20170516 from Debian stretch This was reduced from test-cornerstoragerefwrap.cc in dune-geometry. The issue seemed to start when the CI system upgraded from g++ 8.1 to 8.2, though the fact that that 8.1.0 above also produces the segfault makes me doubt that the reduced issue and the original issue are the same. Ref https://gitlab.dune-project.org/core/dune-geometry/issues/19 (maybe next week when that bugtracker is operational again)