Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 72376 invoked from network); 28 Jul 2008 21:21:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Jul 2008 21:21:38 -0000 Received: (qmail 29801 invoked by uid 500); 28 Jul 2008 21:21:38 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 29780 invoked by uid 500); 28 Jul 2008 21:21:38 -0000 Mailing-List: contact dev-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 dev@stdcxx.apache.org Received: (qmail 29769 invoked by uid 99); 28 Jul 2008 21:21:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jul 2008 14:21:37 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.30.140.160] (HELO moroha.roguewave.com) (208.30.140.160) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jul 2008 21:20:43 +0000 Received: from exchmail01.Blue.Roguewave.Com (exchmail01.blue.roguewave.com [10.22.129.22]) by moroha.roguewave.com (8.13.6/8.13.6) with ESMTP id m6SLJ86g004278 for ; Mon, 28 Jul 2008 21:19:08 GMT X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: string cow bug ([Fwd: Fwd: Update: string COW]) Date: Mon, 28 Jul 2008 15:18:41 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: string cow bug ([Fwd: Fwd: Update: string COW]) Thread-Index: Acjw9Psf9oVVL5HwRgyJmgAzzm4UXgAAfQuA References: <48529C54.5090408@roguewave.com> <7BDB2168BEAEF14C98F1901FD2DE64380277FE41@epmsa009.minsk.epam.com> <488E32BA.2040001@roguewave.com> From: "Travis Vitek" To: X-Virus-Checked: Checked by ClamAV on apache.org =20 Martin Sebor wrote: > >Farid Zaripov wrote: > >> Martin Sebor wrote: >>> >>> ...attached is a test case I got from a fellow attendee of my=20 >>> meeting for what at first blush looks like a COW bug in=20 >>> stdcxx string. The expected output on line 4 is: >>> >>> 2. cc1: 'H' >>> >>=20 >> 21.3.1 p4: >> ----------------------------- >> 4 References, pointers, and iterators referring to the elements of a >> basic_string sequence may be invalidated by the following uses of >> that basic_string object: >> - As an argument to non-member functions swap() (21.3.8.8),=20 >> operator>>() (21.3.8.9), and getline() (21.3.8.9). >> - As an argument to basic_string::swap(). >> - Calling data() and c_str() member functions. >> - Calling non-const member functions, except operator[], at, >> begin, rbegin, end, and rend. >> - Following construction or any of the above uses, except=20 >> the forms of insert and erase that return iterators, the >> first call to non-const member functions operator[], at,=20 >> begin, rbegin, end, or rend. >> ----------------------------- >>=20 >> The first call on non-const operator[] for s1 object=20 >> located in "s1[0] =3D 'H';" line. So after that line any >> references to the elements are invalidated and cc1 >> should not be used after that line. > >But the spec says: > > "...non-const member functions, *except* operator[]..." > >So the non-const overload of string::operator[]() is not >allowed to invalidate references. > I think the last bullet is the most important one. It seems to allow for the first call to op[] to invalidate iterators (and pointers and references). Travis >Martin >