Author: sebor
Date: Sat Oct 20 15:02:54 2007
New Revision: 586811
URL: http://svn.apache.org/viewvc?rev=586811&view=rev
Log:
2007-10-20 Martin Sebor <[EMAIL PROTECTED]>
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 gcc 4 warning: dereferencing type-punned pointer will
break strict-aliasing rules.
Modified:
incubator/stdcxx/branches/4.2.x/include/rw/_rawiter.h
Modified: incubator/stdcxx/branches/4.2.x/include/rw/_rawiter.h
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/include/rw/_rawiter.h?rev=586811&r1=586810&r2=586811&view=diff
==============================================================================
--- incubator/stdcxx/branches/4.2.x/include/rw/_rawiter.h (original)
+++ incubator/stdcxx/branches/4.2.x/include/rw/_rawiter.h Sat Oct 20 15:02:54
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));
}