https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70558
Bug ID: 70558 Summary: POD datatype array crash in initialization when using optimization Product: gcc Version: 5.2.1 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hlprasu at gmail dot com Target Milestone: --- Created attachment 38197 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38197&action=edit Contains example code to reproduce this problem I have created a simple POD class named Double, which encapsulates 'double' type so that comparison operators can be handled in a numerically correct fashion. This is in the attached .tar.gz file. My problem is that if a create a fixed array with it and try to initialize all elements in a single statement then it crashes only when optimization is enabled. E.g.: Double v[3]; v[0] = v[1] = v[2] = 0.0; // <- crash here with -O or -O2 or -O3 Funnily enough, this does not crash if you do v[0] = 0.0; v[1] = 0.0; v[2] = 0.0; To reproduce this error, 1. Untar the attached file and go to the directory tar -xvzf double-pod-crash.tar.gz cd double-pod-crash/ 2. Run 'make' and execute the test file. make ./test # <- This segfaults at the above statement I saw the crash to be at the above statement by using gdb after recompiling with -g option. Please let me know a solution to this problem.