From stdcxx-dev-return-3644-apmail-incubator-stdcxx-dev-archive=incubator.apache.org@incubator.apache.org Tue Jun 05 20:29:37 2007 Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 47510 invoked from network); 5 Jun 2007 20:29:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Jun 2007 20:29:37 -0000 Received: (qmail 15153 invoked by uid 500); 5 Jun 2007 20:29:41 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 15145 invoked by uid 500); 5 Jun 2007 20:29:41 -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 15129 invoked by uid 99); 5 Jun 2007 20:29:41 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jun 2007 13:29:41 -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 Farid_Zaripov@epam.com designates 217.21.63.3 as permitted sender) Received: from [217.21.63.3] (HELO EPMSA009.epam.com) (217.21.63.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jun 2007 13:29:36 -0700 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: [PATCH] RE: [jira] Created: (STDCXX-427) SIGSEGV in istringstream::str() Date: Tue, 5 Jun 2007 23:29:03 +0300 Message-ID: <7BDB2168BEAEF14C98F1901FD2DE64388D199F@epmsa009.minsk.epam.com> In-Reply-To: <465779AD.4020201@roguewave.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] RE: [jira] Created: (STDCXX-427) SIGSEGV in istringstream::str() Thread-Index: AcefKXzWWvGeMipMScC9BBxm12L/CQIgvqEw References: <26166494.1179958456146.JavaMail.jira@brutus> <7BDB2168BEAEF14C98F1901FD2DE6438868EBF@epmsa009.minsk.epam.com> <46563921.8030505@roguewave.com> <7BDB2168BEAEF14C98F1901FD2DE6438869047@epmsa009.minsk.epam.com> <465779AD.4020201@roguewave.com> From: "Farid Zaripov" To: X-Virus-Checked: Checked by ClamAV on apache.org > -----Original Message----- > From: Martin Sebor [mailto:sebor@roguewave.com]=20 > Sent: Saturday, May 26, 2007 3:05 AM > To: stdcxx-dev@incubator.apache.org > Subject: Re: [PATCH] RE: [jira] Created: (STDCXX-427) SIGSEGV=20 > in istringstream::str() >=20 > In input mode (only) the function is supposed to return: >=20 > string(eback(), egptr()); >=20 > In output mode (or input | output) the function must return: >=20 > string(pbase(), high_mark); >=20 > So unless I'm missing something the program below should be a=20 > valid (albeit incomplete) test case. Let me know what you think. >=20 > #include > #include > #include >=20 > int main () > { > struct Buf: std::stringbuf { > Buf (std::string s, std::ios::openmode m) > : std::stringbuf (s, m) { } >=20 > void setget (int beg, int cur, int end) { > setg (eback () + beg, eback () + cur, eback () + end); > } >=20 > void setput (int beg, int cur, int end) { > setp (pbase () + beg, pbase () + end); > pbump (cur); > } > }; >=20 > { > Buf buf ("abcde", std::ios::in); > buf.setget (1, 2, 4); > std::printf ("%s\n", buf.str ().c_str ()); > assert ("bcd" =3D=3D buf.str ()); > } > { > Buf buf ("abcde", std::ios::out); > buf.setput (1, 2, 4); Here setput() doesn't change the highmark, because highmark points past to the last initialized character (in this case points past the 'e') , and buf.str() will return "bcde". > std::printf ("%s\n", buf.str ().c_str ()); > assert ("bcd" =3D=3D buf.str ()); > } > } Farid.