summaryrefslogtreecommitdiff
path: root/smartptr.h
diff options
context:
space:
mode:
Diffstat (limited to 'smartptr.h')
-rw-r--r--smartptr.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/smartptr.h b/smartptr.h
index 82937333..057f5213 100644
--- a/smartptr.h
+++ b/smartptr.h
@@ -79,6 +79,12 @@ public:
T *old_p = m_p;
m_p = 0;
return old_p;
+
+#ifdef __GNUC__
+ // From Andrew Haley (GCC Dev), to tame the optimizer so the assignment is always performed.
+ // See "Disable optimizations in one function" on the GCC mailing list.
+ asm volatile ("" : : : "memory");
+#endif
}
void reset(T *p = 0);