https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115767
--- Comment #33 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to mcccs from comment #31) > Created attachment 61160 [details] > 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. This reduced testcase is definitely undefined because templated_long_s<1> and templated_long_s<0> are not compatiable types; they might have the same layout but they are not compatiable types for aliasing rules.