Author: sebor
Date: Tue Apr 22 10:23:35 2008
New Revision: 650584
URL: http://svn.apache.org/viewvc?rev=650584&view=rev
Log:
2008-04-22 Martin Sebor <[EMAIL PROTECTED]>
* include/valarray.cc (shift, cshift): Consistently used copy- rather
than direct-initialization to work around a gcc 3.2 bug (regression
introduced in rev 650367).
Introduced a temporary for a potential efficiency gain.
Modified:
stdcxx/trunk/include/valarray.cc
Modified: stdcxx/trunk/include/valarray.cc
URL:
http://svn.apache.org/viewvc/stdcxx/trunk/include/valarray.cc?rev=650584&r1=650583&r2=650584&view=diff
==============================================================================
--- stdcxx/trunk/include/valarray.cc (original)
+++ stdcxx/trunk/include/valarray.cc Tue Apr 22 10:23:35 2008
@@ -36,10 +36,15 @@
if (0 == __n)
return *this;
- if (size () <= (_RWSTD_SIZE_T)(__n < 0 ? -__n : __n))
- return valarray (_TypeT (), size ());
+ const _RWSTD_SIZE_T __size = size ();
+
+ if (__size <= (_RWSTD_SIZE_T)(__n < 0 ? -__n : __n))
+ return valarray (__size);
- _RW::__rw_array <_TypeT> __tmp (_TypeT (0), size ());
+ // use copy- rather than direct-initialization to work around
+ // a gcc 3.2 bug
+ _RW::__rw_array<_TypeT> __tmp =
+ _RW::__rw_array<_TypeT>(_TypeT (), __size);
// 26.3.2.7, p5 - negative n shifts right, positive left
if (__n < 0)
@@ -54,15 +59,20 @@
template <class _TypeT>
valarray<_TypeT> valarray<_TypeT>::cshift (int __n) const
{
+ const _RWSTD_SIZE_T __size = size ();
+
// compute non-negative modulus - the sign of (a % b) is
// implementation-defined if either argument is negative (5.6, p4)
- _RWSTD_PTRDIFF_T __mod = size () ? __n % (_RWSTD_PTRDIFF_T)size () : 0;
+ _RWSTD_PTRDIFF_T __mod = __size ? __n % (_RWSTD_PTRDIFF_T)__size : 0;
_RWSTD_SIZE_T __rem = __mod < 0 ? -__mod : __mod;
if (0 == __rem)
return *this;
- _RW::__rw_array<_TypeT> __tmp (_TypeT (), size ());
+ // use copy- rather than direct-initialization to work around
+ // a gcc 3.2 bug
+ _RW::__rw_array<_TypeT> __tmp =
+ _RW::__rw_array<_TypeT>(_TypeT (), __size);
// 26.3.2.7, p7 - negative n rotates right, positive left
rotate_copy (_C_array.begin (),