From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30769 invoked by alias); 8 May 2003 01:46:01 -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 30749 invoked by uid 71); 8 May 2003 01:46:00 -0000 Resent-Date: 8 May 2003 01:46:00 -0000 Resent-Message-ID: <20030508014600.30748.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, daniel.lemire@nrc.gc.ca Received: (qmail 27407 invoked by uid 48); 8 May 2003 01:36:23 -0000 Message-Id: <20030508013623.27406.qmail@sources.redhat.com> Date: Thu, 08 May 2003 01:46:00 -0000 From: daniel.lemire@nrc.gc.ca Reply-To: daniel.lemire@nrc.gc.ca To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: libstdc++/10674: fstream fails to open files in in/out mode if file doesn't exist X-SW-Source: 2003-05/txt/msg00536.txt.bz2 List-Id: >Number: 10674 >Category: libstdc++ >Synopsis: fstream fails to open files in in/out mode if file doesn't exist >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Thu May 08 01:46:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: daniel.lemire@nrc.gc.ca >Release: gcc version 3.4 20030507 (experimental) + gcc version 3.2.3 >Organization: >Environment: linux 2.4.18-3 (RedHat 7.3) on 686 >Description: If one wants to open a file for random access (in/out) so that the compiler automatically createst the file when the file doesn't exist, one would do fstream s("test.txt",ios::in |ios::out); This will fail if fstream when the file doesn't exist. It didn't fail with previous compilers (pre 3.x series). >How-To-Repeat: given the file test.cpp below =================== #include using namespace std; int main() { fstream s("test.txt",ios::in | ios::out); if(!s.is_open()) cout << "bug!"<Fix: Revert back to gcc 2.96 or else FileStream->open( FileName, std::ios::in | std::ios::out); if(! FileStream->is_open()) { FileStream->clear(); FileStream->open( FileName, std::ios::in | std::ios::out| std::ios::trunc); } since the trunc (truncate) apparently allows you to create a file if none is present. The code above is obviously very ugly. >Release-Note: >Audit-Trail: >Unformatted: