summaryrefslogtreecommitdiff
path: root/smartptr.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2015-07-31 10:05:14 -0400
committerJeffrey Walton <noloader@gmail.com>2015-07-31 10:05:14 -0400
commit5f2c32af37152da7607c25df82b392597d05a3c9 (patch)
tree1a7da4586652a005b4236a53da1023d0c9793e20 /smartptr.h
parent79ec88f5a68de169c22df87f0495f98d109ed772 (diff)
downloadcryptopp-git-5f2c32af37152da7607c25df82b392597d05a3c9.tar.gz
Cut-over to inline assembly to tame the optimizer
Diffstat (limited to 'smartptr.h')
-rw-r--r--smartptr.h17
1 files changed, 7 insertions, 10 deletions
diff --git a/smartptr.h b/smartptr.h
index 82d361f7..82937333 100644
--- a/smartptr.h
+++ b/smartptr.h
@@ -45,21 +45,18 @@ private:
void operator=(const simple_ptr<T>& rhs); // assignment not allowed
};
-#if GCC_OPTIMIZE_AWARE
-# pragma GCC push_options
-# pragma GCC optimize ("-O0")
-#endif
-
-// set m_p to NULL so double destruction (which might occur in Singleton) will be harmless
+// Set m_p to NULL so double destruction (which might occur in Singleton) will be harmless
template <class T> simple_ptr<T>::~simple_ptr()
{
delete m_p;
m_p = NULL;
-}
-
-#if GCC_OPTIMIZE_AWARE
-# pragma GCC pop_options
+
+#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
+}
template <class T> class member_ptr
{