From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3599 invoked by alias); 7 Jan 2002 15:16:11 -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 3543 invoked by uid 71); 7 Jan 2002 15:16:05 -0000 Resent-Date: 7 Jan 2002 15:16:04 -0000 Resent-Message-ID: <20020107151604.3542.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, vaniwaar@ca.metsci.com Resent-Reply-To: gcc-gnats@gcc.gnu.org, ron@vaniwaarden.org Received:(qmail 733 invoked by uid 61); 7 Jan 2002 15:06:02 -0000 Message-Id:<20020107150602.731.qmail@sources.redhat.com> Date: Mon, 07 Jan 2002 07:16:00 -0000 From: ron@vaniwaarden.org Reply-To: ron@vaniwaarden.org To: gcc-gnats@gcc.gnu.org Cc: vaniwaar@ca.metsci.com X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) X-GNATS-Notify:vaniwaar@ca.metsci.com Subject: c++/5298: stream::write X-SW-Source: 2002-01/txt/msg00299.txt.bz2 List-Id: >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 #include 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: