https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118396
Bug ID: 118396 Summary: Regression: -O1+ leads to reading uninitialized data when virtual destructor is present Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: carlosgalvezp at gmail dot com Target Milestone: --- Created attachment 60088 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60088&action=edit bug.cpp Hi! We are bumping our GCC install from e9fb6efa1cf542353fd44ddcbb5136344c463fd0 to 979ca3ba366da7177f427e049f67673ec3e35442, and this minimal example (attached) no longer works. Reproducer on Compiler Explorer: https://godbolt.org/z/3e6zfrMEW When using -O1, I see garbage values being read. Valgrind confirms "Conditional jump or move depends on uninitialised value(s)" when reading those values. I have written a couple of comments of changes to the code that make it work as expected. However I don't fully understand why that would be the case, I don't believe there's UB in this snippet, but of course I could be missing something. Looking forward to your feedback, thanks!