https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61674
Bug ID: 61674 Summary: The destructor of a simple class is removed by optimization Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: A.Finch at lancaster dot ac.uk Created attachment 33046 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33046&action=edit Log of compilation In a simple class (LocalGeometryLock) designed to provide a lock the destructor appears to be removed by optimization. This can be prevented by either adding a cout to the destructor or adding __attribute__((optimize("-O0"))) after the destructor definition. This occurs in the code for a large project which it is not practical to send. Unfortunately it has not proved possible to reproduce the issue with a simple test program.