https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63489
Bug ID: 63489 Summary: stack allocated array pointer corrupted Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jonathan.hogg at stfc dot ac.uk Created attachment 33667 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33667&action=edit test case The attached code, when compiled as g++ -g -O2 testcase.cxx -o testcase && ./testcase and run, produces: Try 0x7fff1cbe0a00 0x7fff1cbe0a00 Perm exit: 0 1 2 3 4 5 6 7 GO 0x7fff1cbe0a00 Try2 0x100000000 0x100000000 Segmentation fault g++ --version: g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2 Copyright (C) 2013 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. The lines "Try" and "Try2" should be identical, as they refer to the same stack-allocated array perm[]. Running under valgrind is clean until the last line of ldlt_test() is encountered (which is clearly a segfault as perm is a bad pointer). Compiling without -O2 changes something, and the code crashes differently. I can supply a larger test case (from which this was created) that shuold produce meaningful answers if the code works correctly, but it will need to be provided privately for IP reasons.