This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] libstdc++/41267


Hi,

tested x86_64-linux, committed to mainline.

Paolo.

/////////////////
2009-09-06  Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/41267
	* include/bits/stl_algobase.h (__copy_move::__copy_m,
	__copy_move_backward::__copy_move_b): Don't call __builtin_memmove
	with a null third argument.
Index: include/bits/stl_algobase.h
===================================================================
--- include/bits/stl_algobase.h	(revision 151458)
+++ include/bits/stl_algobase.h	(working copy)
@@ -375,9 +375,10 @@
         static _Tp*
         __copy_m(const _Tp* __first, const _Tp* __last, _Tp* __result)
         {
-	  __builtin_memmove(__result, __first,
-			    sizeof(_Tp) * (__last - __first));
-	  return __result + (__last - __first);
+	  const ptrdiff_t _Num = __last - __first;
+	  if (_Num)
+	    __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
+	  return __result + _Num;
 	}
     };
 
@@ -572,7 +573,8 @@
         __copy_move_b(const _Tp* __first, const _Tp* __last, _Tp* __result)
         {
 	  const ptrdiff_t _Num = __last - __first;
-	  __builtin_memmove(__result - _Num, __first, sizeof(_Tp) * _Num);
+	  if (_Num)
+	    __builtin_memmove(__result - _Num, __first, sizeof(_Tp) * _Num);
 	  return __result - _Num;
 	}
     };

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]