https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115767
--- Comment #31 from mcccs at gmx dot com --- Created attachment 61160 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61160&action=edit minimized.cpp GCC -O1 -fstrict-aliasing or -O2 or -O3: aborts I've attached the minimized human-readable reduced file. I do think it demonstrates GCC's fault in the original file, because if you: change reinterpret_cast<templated_long_s<1> *> near the end of the file to reinterpret_cast<templated_long_s<0> *>, which has the exact same memory layout (the template parameter is a dummy parameter), the produced assembly changes and execution does not abort. ---- Comparing the "optimized" pass output with and without this mutation, it's seen that MEM[(struct templated_long_s *)_9].right = 42; only exists in the correct version. Therefore the testcase has the line reinterpreted->right = 42; completely dropped due to optimization. ---- To experiment with the testcase, you may replace all 4 occurences of "long long" with "long" or "int".