public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: michael.pronath@gmx.de
To: gcc-gnats@gcc.gnu.org
Subject: libstdc++/8636: global ostringstreams lose their data
Date: Mon, 25 Nov 2002 14:42:00 -0000 [thread overview]
Message-ID: <20021119134446.8008.qmail@sources.redhat.com> (raw)
>Number: 8636
>Category: libstdc++
>Synopsis: global ostringstreams lose their data
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Nov 19 05:46:05 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: michael.pronath@gmx.de
>Release: unknown-1.0
>Organization:
>Environment:
Linux glibc2 g++ 3.2
both in debian package and when compiled from source
>Description:
global ostringstreams lose their data after calling
c_str on them when new memory is allocated.
See appended example.
Expected output: Hello World, where are you?
real output: Hello Hello Hello Hello Hell
reason: when fillmystream() returns, the ostringstream content is forgotten, just like it was an automatic
variable. The string operator+= then allocates new memory
for extension of the string and gets the address of x and
then appends itself.
Interestingly, this does not happen in valgrind.
>How-To-Repeat:
g++ -o teststream teststream.cc
./teststream
valgrind ./teststream
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="teststream.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="teststream.cc"
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3N0cmVhbT4KI2luY2x1ZGUgPHN0cmluZz4K
CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpvc3RyaW5nc3RyZWFtIHRlc3RzdHJlYW07CmNvbnN0IGNo
YXIgKng7Cgp2b2lkIGZpbGxteXN0cmVhbSgpCnsKICAgdGVzdHN0cmVhbSA8PCAiIFdvcmxkLCB3
aGVyZSBhcmUgeW91PyI7CiAgIHggPSB0ZXN0c3RyZWFtLnN0cigpLmNfc3RyKCk7CiAgIHJldHVy
bjsKfQogICAKaW50IG1haW4oKQp7CiAgIHN0cmluZyB0ZXN0c3RyaW5nPSIiOwogICBmaWxsbXlz
dHJlYW0oKTsKICAgdGVzdHN0cmluZyA9ICJIZWxsbyAiOwogICB0ZXN0c3RyaW5nICs9IHg7CiAg
IGNvdXQgPDwgInRlc3RzdHJpbmcgaXMgJyIgPDwgdGVzdHN0cmluZyA8PCAiJyIgPDwgZW5kbDsK
fQoK
next reply other threads:[~2002-11-19 13:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-25 14:42 michael.pronath [this message]
2002-11-28 8:06 paolo
2002-11-30 20:01 Paolo Carlini
2002-11-30 20:56 Michael Pronath
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021119134446.8008.qmail@sources.redhat.com \
--to=michael.pronath@gmx.de \
--cc=gcc-gnats@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).