public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/8466: basic_stringbuf::str(basic_string const&) modifies its argument
@ 2002-11-05 13:34 paolo
  0 siblings, 0 replies; 3+ messages in thread
From: paolo @ 2002-11-05 13:34 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, gnats, nobody, paolo

Synopsis: basic_stringbuf::str(basic_string const&) modifies its argument

Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Tue Nov  5 13:34:00 2002
Responsible-Changed-Why:
    Analyzed.
State-Changed-From-To: open->analyzed
State-Changed-By: paolo
State-Changed-When: Tue Nov  5 13:34:00 2002
State-Changed-Why:
    Confirmed. I have a one-liner fix ready but want to delve
    a little more deeply into the issue before proposing it.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8466


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: libstdc++/8466: basic_stringbuf::str(basic_string const&) modifies its argument
@ 2002-11-05 15:36 paolo
  0 siblings, 0 replies; 3+ messages in thread
From: paolo @ 2002-11-05 15:36 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, gnats, paolo

Synopsis: basic_stringbuf::str(basic_string const&) modifies its argument

State-Changed-From-To: analyzed->closed
State-Changed-By: paolo
State-Changed-When: Tue Nov  5 15:36:53 2002
State-Changed-Why:
    Fixed for 3.2.1 and 3.3.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8466


^ permalink raw reply	[flat|nested] 3+ messages in thread

* libstdc++/8466: basic_stringbuf::str(basic_string const:) modifies its argument
@ 2002-11-05 12:06 gnats
  0 siblings, 0 replies; 3+ messages in thread
From: gnats @ 2002-11-05 12:06 UTC (permalink / raw)
  To: gcc-gnats


>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 <sstream>
    #include <cassert>

    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:


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-11-05 23:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-05 13:34 libstdc++/8466: basic_stringbuf::str(basic_string const&) modifies its argument paolo
  -- strict thread matches above, loose matches on Subject: below --
2002-11-05 15:36 paolo
2002-11-05 12:06 libstdc++/8466: basic_stringbuf::str(basic_string const:) " gnats

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).