Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 72148 invoked from network); 18 Jul 2007 00:58:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Jul 2007 00:58:38 -0000 Received: (qmail 35004 invoked by uid 500); 18 Jul 2007 00:58:34 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 34988 invoked by uid 500); 18 Jul 2007 00:58:34 -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 34977 invoked by uid 99); 18 Jul 2007 00:58:34 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jul 2007 17:58:34 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of msebor@gmail.com designates 209.85.146.179 as permitted sender) Received: from [209.85.146.179] (HELO wa-out-1112.google.com) (209.85.146.179) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jul 2007 17:58:28 -0700 Received: by wa-out-1112.google.com with SMTP id n4so84812wag for ; Tue, 17 Jul 2007 17:58:07 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:organization:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=QiqJb1rRQrKS9B2oJRdQen59Y7t+OzrPFvBg7YucFmvIcmgaUrJaAMKqH+bFvYxYUOyutlWPsNP+FDP4GkGm/8eFK9hK/2gzqdHezwBnVsHCBoleCebV5UBF6+XYdKCick/ZmFkZqgfxAnGN5s3h0E+zT+OTjQljzgdqxEIoaGI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:organization:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=jQHEy8isz9oNng5ijtM9iMU1GhVPc+vpE1WPPfF0H0HNvP1dubYQN1XxUFyonqWfzQaykaj7kX3HuKVGSflAQhpwjpyCahqBKC/mRV3uOW7T5OLbzSQFcoNsr1JByOzQ2UW/1edgGasEExVpIbnWJui2gT2lQb9ED93mVT8xbGA= Received: by 10.114.175.16 with SMTP id x16mr936474wae.1184720287396; Tue, 17 Jul 2007 17:58:07 -0700 (PDT) Received: from ?192.168.1.104? ( [71.229.200.170]) by mx.google.com with ESMTPS id m25sm260071waf.2007.07.17.17.58.05 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 17 Jul 2007 17:58:05 -0700 (PDT) Message-ID: <469D659C.3020201@roguewave.com> Date: Tue, 17 Jul 2007 18:58:04 -0600 From: Martin Sebor Organization: Rogue Wave Software User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.0.12) Gecko/20070531 Fedora/1.0.9-1.fc6 pango-text SeaMonkey/1.0.9 MIME-Version: 1.0 To: stdcxx-dev@incubator.apache.org Subject: Re: [patch] STDCXX-170 References: <7BDB2168BEAEF14C98F1901FD2DE6438B00AA5@epmsa009.minsk.epam.com> In-Reply-To: <7BDB2168BEAEF14C98F1901FD2DE6438B00AA5@epmsa009.minsk.epam.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: Martin Sebor X-Virus-Checked: Checked by ClamAV on apache.org Farid Zaripov wrote: > Here is proposed patch to fix STDCXX-170 issue: > > ChangeLog: > * string.cc (replace): Copy data to temporary string object > if data is a part of the internal string buffer. > > Index: string.cc > =================================================================== > --- string.cc (revision 556830) > +++ string.cc (working copy) > @@ -516,6 +516,15 @@ > _RWSTD_ASSERT_RANGE (__first1, __last1); > _RWSTD_ASSERT_RANGE (__first2, __last2); > > + if ( !(__first2 == __last2) > + && __s._C_data <= &*__first2 > + && __s._C_data + __s.size () > &*__first2) { I don't think this exression is guaranteed to be well-formed. InputIterator's operator* can return an rvalue (rather than a const reference) which would break operator &. The test case below should compile. Does it with your change? It should also run successfully to completion but in debug builds it aborts instead. That looks like a bug in our implementation of the debugging iterators. #include #include struct Iterator: std::string::const_reverse_iterator { char operator* () const { return std::string::const_reverse_iterator::operator* (); } }; int main () { std::string s; s.replace (s.begin (), s.end (), Iterator (), Iterator ()); } Martin > + > + // __first2 points to internal string buffer > + return __s.replace (__first1, __last1, > + basic_string (__first2, __last2)); > + } > + > // use a (probably) faster algorithm if possible > if > (_STD::__is_bidirectional_iterator(_RWSTD_ITERATOR_CATEGORY(_InputIter, > > __last2))) > > > Farid. >