public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cctsai57 at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/67600] New: [5/6] Segfault when assigning only one char to ostreambuf_iterator<char> compiled with -O2 or -O3 Date: Wed, 16 Sep 2015 11:23:00 -0000 [thread overview] Message-ID: <bug-67600-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67600 Bug ID: 67600 Summary: [5/6] Segfault when assigning only one char to ostreambuf_iterator<char> compiled with -O2 or -O3 Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: cctsai57 at gmail dot com Target Milestone: --- #include <iostream> #include <sstream> int main() { std::basic_ostringstream<char> ostr; std::ostreambuf_iterator<char> iter(ostr.rdbuf()); *iter++ = 'X'; // Segmentation fault if -O2 or -O3. // *iter++ = 'Y'; // But pass if adding this statement. std::cout << ostr.str() << '\n'; return 0; } Description: If the above simplified code is compiled with -O2 or -O3, segmentation fault happens in "*iter++ = 'x'" statement, but -O0, -O1 or -Os are O.K. If I add the "*iter++ = 'Y'" statement and compile it with -O2 or -O3, it can print "XY" successfully. gcc versions: Fails on gcc-5 (x86_64-redhat-linux on Fedora-22) and gcc-6.0.0 (20150916 (experimental)). Pass on gcc-4.8 and gcc-4.9
next reply other threads:[~2015-09-16 11:23 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-09-16 11:23 cctsai57 at gmail dot com [this message] 2015-09-16 11:35 ` [Bug ipa/67600] [5/6 Regression] " rguenth at gcc dot gnu.org 2015-09-16 11:37 ` rguenth at gcc dot gnu.org 2015-10-12 8:15 ` hubicka at gcc dot gnu.org 2015-10-16 6:08 ` hubicka at gcc dot gnu.org 2015-10-24 17:02 ` miyuki at gcc dot gnu.org 2015-10-24 17:34 ` trippels at gcc dot gnu.org 2015-10-25 14:13 ` hjl.tools at gmail dot com 2015-10-28 13:44 ` [Bug ipa/67600] [5 " rguenth at gcc dot gnu.org 2015-10-28 13:44 ` rguenth at gcc dot gnu.org
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=bug-67600-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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: linkBe 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).