From commits-return-2793-apmail-stdcxx-commits-archive=stdcxx.apache.org@stdcxx.apache.org Tue Apr 22 17:24:01 2008 Return-Path: Delivered-To: apmail-stdcxx-commits-archive@www.apache.org Received: (qmail 23633 invoked from network); 22 Apr 2008 17:24:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Apr 2008 17:24:01 -0000 Received: (qmail 21327 invoked by uid 500); 22 Apr 2008 17:24:02 -0000 Delivered-To: apmail-stdcxx-commits-archive@stdcxx.apache.org Received: (qmail 21277 invoked by uid 500); 22 Apr 2008 17:24:02 -0000 Mailing-List: contact commits-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list commits@stdcxx.apache.org Received: (qmail 21251 invoked by uid 99); 22 Apr 2008 17:24:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Apr 2008 10:24:02 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Apr 2008 17:23:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 37F3B1A9832; Tue, 22 Apr 2008 10:23:38 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r650584 - /stdcxx/trunk/include/valarray.cc Date: Tue, 22 Apr 2008 17:23:37 -0000 To: commits@stdcxx.apache.org From: sebor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080422172338.37F3B1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 * 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 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 (),