From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20019 invoked by alias); 5 Nov 2002 20:06:00 -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 19999 invoked by uid 71); 5 Nov 2002 20:06:00 -0000 Resent-Date: 5 Nov 2002 20:06:00 -0000 Resent-Message-ID: <20021105200600.19997.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, gnats@kayari.org Received: (qmail 15428 invoked from network); 5 Nov 2002 19:57:44 -0000 Received: from unknown (HELO holyghost.redi.uklinux.net) (194.247.48.126) by sources.redhat.com with SMTP; 5 Nov 2002 19:57:44 -0000 Received: (from redi@localhost) by holyghost.redi.uklinux.net (8.11.6/8.11.6) id gA5JuFg03783; Tue, 5 Nov 2002 14:56:15 -0500 Message-Id: <200211051956.gA5JuFg03783@holyghost.redi.uklinux.net> Date: Tue, 05 Nov 2002 12:06:00 -0000 From: gnats@kayari.org To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: 3.113 Subject: libstdc++/8466: basic_stringbuf::str(basic_string const:) modifies its argument X-SW-Source: 2002-11/txt/msg00247.txt.bz2 List-Id: >Number: 8466 >Category: libstdc++ >Synopsis: basic_stringbuf::str(basic_string const&) modifies its argument >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Tue Nov 05 12:06:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Jonathan Wakely >Release: 3.3 20021021 (experimental) >Organization: >Environment: System: Linux holyghost.redi.uklinux.net 2.4.19 #44 Thu Aug 8 23:05:18 BST 2002 i586 unknown Architecture: i586 host: i586-pc-linux-gnu build: i586-pc-linux-gnu target: i586-pc-linux-gnu configured with: ../gcc/configure --prefix=/home/redi --enable-languages=c,c++ --program-suffix=3x --disable-nls >Description: The program below aborts on the second assertion, but I believe it should finish normally. The basic_stringbuf::str() overload taking an argument should copy the string's contents to the buffer, instead it appears to be sharing the string's internal representation so that writing to the stream modifies the (possibly const) string. >How-To-Repeat: Run the following program: #include #include int main() { const char* orig = "0123456789"; const std::string s = orig; std::ostringstream o(s); o << "abcde"; assert(s == orig); // PASS o.str(s); o << "abcde"; assert(s == orig); // FAIL! const string was modified! } This gives: a.out: sstream_buf_share.cc:15: int main(): Assertion `s == orig' failed. >Fix: >Release-Note: >Audit-Trail: >Unformatted: