This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/61674] The destructor of a simple class is removed by optimization


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]