stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r586813 - /incubator/stdcxx/branches/4.2.0/include/rw/_rawiter.h
Date Sat, 20 Oct 2007 22:04:25 GMT
Author: sebor
Date: Sat Oct 20 15:04:24 2007
New Revision: 586813

URL: http://svn.apache.org/viewvc?rev=586813&view=rev
Log:
2007-10-20  Martin Sebor  <sebor@roguewave.com>

	Merged rev 586811 from branches/4.2.x with a fix for STDCXX-350.
	* _rawiter.h [__GNUG__ >= 4] (get_temporary_buffer,
	return_temporary_buffer): Used __attribute__ (may_alias) to tell
	the gcc optimizier about type-punning in a reinterpret_cast()
	and to silence warning: dereferencing type-punned pointer will
	break strict-aliasing rules.

Modified:
    incubator/stdcxx/branches/4.2.0/include/rw/_rawiter.h

Modified: incubator/stdcxx/branches/4.2.0/include/rw/_rawiter.h
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/include/rw/_rawiter.h?rev=586813&r1=586812&r2=586813&view=diff
==============================================================================
--- incubator/stdcxx/branches/4.2.0/include/rw/_rawiter.h (original)
+++ incubator/stdcxx/branches/4.2.0/include/rw/_rawiter.h Sat Oct 20 15:04:24 2007
@@ -36,7 +36,7 @@
  * implied.   See  the License  for  the  specific language  governing
  * permissions and limitations under the License.
  *
- * Copyright 1994-2006 Rogue Wave Software.
+ * Copyright 1994-2007 Rogue Wave Software, Inc.
  * 
  **************************************************************************/
 
@@ -135,8 +135,19 @@
 {
     pair<_TypeT*, _Distance> __res (0, 0);
 
+#if __GNUG__ >= 4
+
+    // tell gcc 4 about type-punning in the cast below
+    typedef void* __attribute__ ((__may_alias__)) _VoidPtrT;
+
+#else   // !gcc || gcc < 4
+
+    typedef void* _VoidPtrT;
+
+#endif   // gcc
+
     __res.second =
-        _RW::__rw_tmpbuf (_RWSTD_REINTERPRET_CAST (void**, &__res.first),
+        _RW::__rw_tmpbuf (_RWSTD_REINTERPRET_CAST (_VoidPtrT*, &__res.first),
                           __nelems < 0 ? 0 : __nelems, sizeof (_TypeT));
 
     return __res;
@@ -161,7 +172,18 @@
 inline void
 return_temporary_buffer (_TypeT *__p)
 {
-    _RW::__rw_tmpbuf (_RWSTD_REINTERPRET_CAST (void**, &__p),
+#if __GNUG__ >= 4
+
+    // tell gcc 4 about type-punning in the cast below
+    typedef void* __attribute__ ((__may_alias__)) _VoidPtrT;
+
+#else   // !gcc || gcc < 4
+
+    typedef void* _VoidPtrT;
+
+#endif   // gcc
+
+    _RW::__rw_tmpbuf (_RWSTD_REINTERPRET_CAST (_VoidPtrT*, &__p),
                       0, sizeof (_TypeT));
 }
 



Mime
View raw message