From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8805 invoked by alias); 11 Apr 2002 23:56:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 8775 invoked by uid 71); 11 Apr 2002 23:56:02 -0000 Date: Thu, 11 Apr 2002 16:56:00 -0000 Message-ID: <20020411235602.8774.qmail@sources.redhat.com> To: gdr@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Gabriel Dos Reis Subject: Re: libstdc++/6090: Problem with copy of std_valarray Reply-To: Gabriel Dos Reis X-SW-Source: 2002-04/txt/msg00636.txt.bz2 List-Id: The following reply was made to PR libstdc++/6090; it has been noted by GNATS. From: Gabriel Dos Reis To: Benjamin Kosnik Cc: gdr@gcc.gnu.org, gcc-gnats@gcc.gnu.org Subject: Re: libstdc++/6090: Problem with copy of std_valarray Date: 12 Apr 2002 01:53:10 +0200 Benjamin Kosnik writes: | The following reply was made to PR libstdc++/6090; it has been noted by GNATS. | | From: Benjamin Kosnik | To: Gabriel Dos Reis | Cc: erwan.goasdoue@ipsis.fr, gcc-bugs@gcc.gnu.org, gdr@gcc.gnu.org, | gcc-gnats@gcc.gnu.org | Subject: Re: libstdc++/6090: Problem with copy of std_valarray | Date: Wed, 10 Apr 2002 09:49:17 -0700 (PDT) | | > That is the mandated behaviour, in particular if the source and the | > target don't have the same length then the behaviour is undefined. | | I think the problem is that the assignment and copy ctor do different | things. Why is that? (I'm not sure that is really a problem). The copy constructor is supposed to construct a new object out of an existing one, whereas the assignment operator is supposed to assign values to components of an existing object. Those two operations are fundamentally semantically different. Valarray<>'s design is more driven by speed than by security; the assignement operator is more memcpy()-like than std::vector<>::operator=()-like. That was a design choice explained by the fact that valarray<>s are meant to be basic blocks with "basic" operations. -- Gaby