[Bug c++/62006] New: Bad code generation with -O3 (possibly due to -ftree-partial-pre)
tkoeppe at google dot com
Mon Aug 4 10:40:00 GMT 2014
Bug ID: 62006
Summary: Bad code generation with -O3 (possibly due to
Assignee: unassigned at gcc dot gnu.org
Reporter: tkoeppe at google dot com
Created attachment 33231
Demonstrates bad code generation with -O3
I was writing some code to demonstrate custom allocators with fancy pointers.
While testing it with GCC, I noticed memory corruption when compiling with -O3.
Jonathan Wakely had a quick look and narrowed it down to "-O2
-ftree-partial-pre"; with just "-O2" the code works.
I don't have any insights in the problem, so I'm just attaching the full code.
You can tell that it's broken by passing the program through valgrind, or
simply by noting that it prints all container elements as zero, rather than
their actual values.
(Incidentally, I believe there's a similar problem in Clang:
More information about the Gcc-bugs