libstdc++ diff: using tr1/memory should work with -fno-rtti

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

libstdc++ diff: using tr1/memory should work with -fno-rtti

Vladimir Kirillov-2
Hello, tech@!

Currently, the c++ tr1 implementation in OpenBSD tree implicitly uses
typeid() in shared_ptr<>, thus using -fno-rtti is not possible here.

It turns out that gcc guys came onto the issue only a year ago:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42019

The diff:

Index: tr1/boost_shared_ptr.h
===================================================================
RCS file: /cvs/src/gnu/gcc/libstdc++-v3/include/tr1/boost_shared_ptr.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 boost_shared_ptr.h
--- tr1/boost_shared_ptr.h 15 Oct 2009 17:11:32 -0000 1.1.1.1
+++ tr1/boost_shared_ptr.h 28 Oct 2010 21:49:29 -0000
@@ -247,7 +247,13 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
       
       virtual void*
       _M_get_deleter(const std::type_info& __ti)
-      { return __ti == typeid(_Deleter) ? &_M_del : 0; }
+      {
+#ifdef __GXX_RTTI
+        return __ti == typeid(_Deleter) ? &_M_del : 0;
+#else
+        return 0;
+#endif
+      }
       
     private:
       _Sp_counted_base_impl(const _Sp_counted_base_impl&);
@@ -780,7 +786,13 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
   template<typename _Del, typename _Tp, _Lock_policy _Lp>
     inline _Del*
     get_deleter(const __shared_ptr<_Tp, _Lp>& __p)
-    { return static_cast<_Del*>(__p._M_get_deleter(typeid(_Del))); }
+    {
+#ifdef __GXX_RTTI
+      return static_cast<_Del*>(__p._M_get_deleter(typeid(_Del)));
+#else
+      return 0;
+#endif
+    }
 
 
   template<typename _Tp, _Lock_policy _Lp>