Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 51873 invoked from network); 1 Jun 2007 21:42:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Jun 2007 21:42:36 -0000 Received: (qmail 85814 invoked by uid 500); 1 Jun 2007 21:42:40 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 85799 invoked by uid 500); 1 Jun 2007 21:42:40 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 85788 invoked by uid 99); 1 Jun 2007 21:42:40 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jun 2007 14:42:40 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jun 2007 14:42:35 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 96C35714186 for ; Fri, 1 Jun 2007 14:42:15 -0700 (PDT) Message-ID: <16996378.1180734135598.JavaMail.jira@brutus> Date: Fri, 1 Jun 2007 14:42:15 -0700 (PDT) From: "Martin Sebor (JIRA)" To: stdcxx-dev@incubator.apache.org Subject: [jira] Commented: (STDCXX-319) std::filebuf::open(..., ios::app) unexpectedly succeeds In-Reply-To: <8866963.1168974327781.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/STDCXX-319?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12500868 ] Martin Sebor commented on STDCXX-319: ------------------------------------- This is actually by design and documented (for ifstream and ofstream) in the User's Guide. Classic Iostream behavior is the same as is C stdio. Quoting from http://incubator.apache.org/stdcxx/doc/stdlibug/index.html: 30.3.1.1 The in and out Open Modes Input (and output) file streams always have the in (or out) open mode flag set implicitly. An output file stream, for instance, knows that it is in output mode and you need not set the output mode explicitly. Instead of writing: std::ofstream Str("out.txt", std::ios_base::out | std::ios_base::app); you can simply say: std::ofstream Str("out.txt", std::ios_base::app); Bidirectional file streams, on the other hand, do not have the flag set implicitly. This is because a bidirectional stream does not have to be in both input and output mode in all cases. You might want to open a bidirectional stream for reading only or writing only. Bidirectional file streams therefore have no implicit input or output mode. You must always set a bidirectional file stream's open mode explicitly. > std::filebuf::open(..., ios::app) unexpectedly succeeds > ------------------------------------------------------- > > Key: STDCXX-319 > URL: https://issues.apache.org/jira/browse/STDCXX-319 > Project: C++ Standard Library > Issue Type: Bug > Components: 27. Input/Output > Affects Versions: 4.1.3, 4.1.2 > Environment: all > Reporter: Martin Sebor > Assignee: Martin Sebor > > According to filebuf.members, p2, filebuf::open(const char*, openmode mode) is not some combination of the flags listed in Table 113 the call is supposed to fail. Since ios::app only appears in conjunction with ios::out (and ios::binary|ios::out) the call in the program below should fail. > $ cat t.cpp && make t && ./t > #include > #include > int main () > { > std::filebuf fb; > const std::filebuf* const pfb = fb.open ("dummy", std::ios::app); > assert (0 == pfb); > } > gcc -c -I/build/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG -D_RWSTD_USE_CONFIG -I/build/sebor/dev/stdlib/include -I/build/sebor/gcc-4.1.0-11s/include -I/build/sebor/dev/stdlib/../rwtest -I/build/sebor/dev/stdlib/../rwtest/include -I/build/sebor/dev/stdlib/tests/include -pedantic -nostdinc++ -g -W -Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long t.cpp > gcc t.o -o t -L/build/sebor/gcc-4.1.0-11s/rwtest -lrwtest11s -L/build/sebor/gcc-4.1.0-11s/lib -lstd11s -lsupc++ -lm > Assertion failed: 0 == pfb, file t.cpp, line 10 > Abort (core dumped) -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.