diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp index c9240e534c7..37a217fc8c5 100644 --- a/lib/VMCore/Attributes.cpp +++ b/lib/VMCore/Attributes.cpp @@ -131,8 +131,8 @@ public: } void DropRef() { sys::SmartScopedLock Lock(*ALMutex); - sys::cas_flag old = RefCount++; - if (old == 1) + sys::cas_flag new_val = RefCount--; + if (new_val == 0) delete this; }