From stdcxx-dev-return-3551-apmail-incubator-stdcxx-dev-archive=incubator.apache.org@incubator.apache.org Tue May 29 23:38:39 2007 Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 77887 invoked from network); 29 May 2007 23:38:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 May 2007 23:38:38 -0000 Received: (qmail 33472 invoked by uid 500); 29 May 2007 23:38:42 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 33415 invoked by uid 500); 29 May 2007 23:38:42 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 33282 invoked by uid 99); 29 May 2007 23:38:41 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 May 2007 16:38:41 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 May 2007 16:38:36 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 30B84714180 for ; Tue, 29 May 2007 16:38:16 -0700 (PDT) Message-ID: <21460116.1180481896197.JavaMail.jira@brutus> Date: Tue, 29 May 2007 16:38:16 -0700 (PDT) From: "Martin Sebor (JIRA)" To: stdcxx-dev@incubator.apache.org Subject: [jira] Assigned: (STDCXX-224) std::valarray::operator[](slice) broken In-Reply-To: <15193261.1151519009842.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/STDCXX-224?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Martin Sebor reassigned STDCXX-224: ----------------------------------- Assignee: Martin Sebor > std::valarray::operator[](slice) broken > --------------------------------------- > > Key: STDCXX-224 > URL: https://issues.apache.org/jira/browse/STDCXX-224 > Project: C++ Standard Library > Issue Type: Bug > Components: 26. Numerics > Affects Versions: 4.1.3, 4.1.2 > Environment: all > Reporter: Martin Sebor > Assignee: Martin Sebor > > Moved from the Rogue Wave bug tracking database: > ****Created By: sebor @ Mar 16, 2003 06:51:05 PM**** > Subject: CXX-DEV: Bug in valarray / slice_array? > mario.konijnenburg@philips.com > Date: 03/13/03 > next message: Martin Sebor: "Re: CXX-DEV: Bug in valarray / slice_array?" > previous message: Dennis Handly: "Re: CXX-DEV: Suggestions re cause of crash when shl_load'ing" > Next in thread: Martin Sebor: "Re: CXX-DEV: Bug in valarray / slice_array?" > reply: Martin Sebor: "Re: CXX-DEV: Bug in valarray / slice_array?" > Hello, > The following program results in incorrect results: > #include > #include > int main() { > int vals[] = {1,0}; > const std::valarray p( vals, 2 ); > for ( int i =0; i std::cout << "p:" << i << "=" << p[i] << std::endl; > > const std::valarray r = p[ std::slice( 0, 0, 1 ) ]; > for ( int i =0; i std::cout << "r:" << i << "=" << r[i] << std::endl; > return 0; > } > Output: > LT:tmp 223 0>aCC -AA -g1 -o val.hp val2.C > LT:tmp 224 0>./val.hp > p:0=1 > p:1=0 > r:0=0 > r:1=0 > A slice is specified with size 0. Therefore I expect that valarray 'r' is > of size 0 and no output should > appear for 'r'. > Note that I make use of -const- valarrays. In that case a valarray is > returned by valarray::operator[]. > The problem disappears when I remove the 'const's. In that case a > slice_array is > returned by valarray::operator[] and used to construct valarray 'r'. The > output when 'const' is removed is: > LT:tmp 226 0>./val.hp > p:0=1 > p:1=0 > Compiler: aCC: HP ANSI C++ B3910B A.03.37 > Do I something wrong or is this a compiler / library bug? > Thanks. > Regards, Mario. > Mario.Konijnenburg@philips.com > Philips Research Laboratories; Electronic Design & Tools; > Building WAY3.27, Prof. Holstlaan 4 Phone: +31 (0)40 2743728 > 5656 AA Eindhoven, The Netherlands Fax: +31 (0)40 2744626 > _________________________________________________________________ > To leave this mailing list, send mail to majordomo@cxx.cup.hp.com > with the message UNSUBSCRIBE cxx-dev > _________________________________________________________________ > ****Modified By: sebor @ Mar 16, 2003 06:59:07 PM**** > -------- Original Message -------- > Subject: [Fwd: Re: CXX-DEV: Bug in valarray / slice_array?] > Date: Sun, 16 Mar 2003 18:49:46 -0700 > From: Martin Sebor > Organization: Rogue Wave Software, Inc. > To: Dennis Handly > Dennis, > Here's a fix for the bug if you want to incorporate it. From > briefly looking at I suspect that there are a ton > of subtle and not so subtle bugs such as this one and even > more efficiency improvements that could be made; a complete > rewrite will probably be necessary to make the class(es) > useful. > Martin > template > inline valarray<_TypeT> > valarray<_TypeT>::operator[] (slice __sl) const > { > if (0 == __sl.size ()) > return valarray<_TypeT>(); > _RWSTD_ASSERT (__sl.start () < size ()); > _RWSTD_ASSERT (0 != __sl.stride ()); > const _RWSTD_SIZE_T __size = > size () < __sl.start () + __sl.size () * __sl.stride () ? > (size () - __sl.start ()) / __sl.stride () : __sl.size (); > _RWSTD_ASSERT (__size <= size ()); > _RW::__rw_array <_TypeT> __tmp = > _RW::__rw_array <_TypeT>(_TypeT (), __size); > for (_RWSTD_SIZE_T __i = __sl.start (), __j = 0; __j != __size; > __i += __sl.stride (), ++__j) > __tmp [__j] = _C_array [__i]; > return valarray<_TypeT>(__tmp); > } > -------- Original Message -------- > Subject: Re: CXX-DEV: Bug in valarray / slice_array? > Date: Fri, 14 Mar 2003 11:53:24 -0700 > From: Martin Sebor > Reply-To: cxx-dev@cxx.cup.hp.com > Organization: Rogue Wave Software, Inc. > To: cxx-dev@cxx.cup.hp.com > References: > > mario.konijnenburg@philips.com wrote: > > Hello, > > > > The following program results in incorrect results: > > > ... > > > > A slice is specified with size 0. Therefore I expect that valarray > 'r' is > > of size 0 and no output should > > appear for 'r'. > > Note that I make use of -const- valarrays. In that case a valarray is > > returned by valarray::operator[]. > > > > The problem disappears when I remove the 'const's. In that case a > > slice_array is > > returned by valarray::operator[] and used to construct valarray 'r'. The > > output when 'const' is removed is: > > LT:tmp 226 0>./val.hp > > p:0=1 > > p:1=0 > > > > Compiler: aCC: HP ANSI C++ B3910B A.03.37 > > > > > > Do I something wrong or is this a compiler / library bug? > It's a bug in valarray::operator[](slice) const. > Regards > Martin -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.