This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/61674] The destructor of a simple class is removed by optimization
- From: "A.Finch at lancaster dot ac.uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 03 Jul 2014 09:19:37 +0000
- Subject: [Bug c++/61674] The destructor of a simple class is removed by optimization
- Auto-submitted: auto-generated
- References: <bug-61674-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61674
--- Comment #6 from Alex Finch <A.Finch at lancaster dot ac.uk> ---
I guess I should have made that clear. The class has a static variable:
static int fLockCount;
which counts how many times an object of the class is created.
If it is >1, then IsLocked() returns true. The destructor has a line
--fLockCount;
which is not executed if the destructor is not called. This breaks the program.
The destructor should not be optimised out precisely because it modifies the
static variable.