public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: ron@vaniwaarden.org To: gcc-gnats@gcc.gnu.org Cc: vaniwaar@ca.metsci.com Subject: c++/5298: stream::write Date: Mon, 07 Jan 2002 07:16:00 -0000 [thread overview] Message-ID: <20020107150602.731.qmail@sources.redhat.com> (raw) >Number: 5298 >Category: c++ >Synopsis: stream::write >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Mon Jan 07 07:16:02 PST 2002 >Closed-Date: >Last-Modified: >Originator: Ronald Van Iwaarden >Release: gcc version 3.0.2 20010905 (Red Hat Linux 7.1 3.0.1-3) >Organization: >Environment: Redhat Linux version 7.2 with g++3 installed. >Description: ostreams now flush() after every call to ostream::write(char*, int) because the write() call calls sync() which, in turn, calls flush(). This is a change from prior versions and other compilers. The prior behavior was to flush at every endl. This behavior can significantly degrade performance of IO, not to mention, results in unexpected behavior. I don't know if this is actually a bug but it certainly caught me off guard and is going to prevent use of g++ version 3.0 without significant modifications to our code... >How-To-Repeat: Execute the following program on an OS that supports fork(). On g++ 2.9.*, it would print out 3.1416 3.1416 but on 3.0.2, it prints out 33..1411461 6 or other slight variations on the order because of timing issues: #include <iostream.h> #include <unistd.h> int main() { int pid= fork(); if (pid) sleep(1); cout.write("3", 1); sleep(1); cout.write(".", 1); sleep(1); cout.write("1", 1); sleep(1); cout.write("4", 1); sleep(1); cout.write("1", 1); sleep(1); cout.write("6", 1); sleep(1); cout.write("\n", 1); sleep(1); } >Fix: Not sure except that I don't think the stream should flush after every write call... >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2002-01-07 15:16 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-01-07 7:16 ron [this message] 2002-01-07 14:16 paolo 2002-01-08 9:51 paolo 2002-01-08 10:06 Ronald Van Iwaarden
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=20020107150602.731.qmail@sources.redhat.com \ --to=ron@vaniwaarden.org \ --cc=gcc-gnats@gcc.gnu.org \ --cc=vaniwaar@ca.metsci.com \ /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).