delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/22/08:53:35

From: "Ian Miller" <Ian AT shelob DOT force9 DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DJGPP 2.01 / GCC 2.8.1 implementation flaw
Date: Sun, 22 Nov 1998 13:25:36 -0000
Organization: Force9 Internet
Lines: 40
Message-ID: <73929j$ee$1@news1.force9.net>
References: <fycflpbqrpbz DOT f2r86i0 DOT pminews AT nntp DOT generation DOT net>
NNTP-Posting-Host: 16.hiper01.shef.dialup.force9.net
X-Newsreader: Microsoft Outlook Express 4.71.1712.3
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

sl wrote in message ...
> According to my trusty book here, ofstream defaults to using
>ios::trunc when opening file...
>
> Looking at the implementation  I found the... constructor
>defaults "mode" to "ios::out" .. when I use ios::trunc in place and override
>the default, the file knows it should open in truncate mode, but it does not
>know to open in output mode. I believe this is an implementation fault: no
>matter what the programmer specifies, ofstream should ALWAYS use ios::out and
>when someone chooses to do
>
>ofstream someFile("hello.txt", ios::trunc);
>
> like me, it should know that really means ios::out|ios::trunc.. After
>all, that *is* the definition of the ofstream class. Any suggestions,
>comments?


I think you are correct. I think you are reporting it to the wrong
newsgroup, but I think you are correct :)

From the C++ standard working paper of Nov 97 obtained from
http://www.cygnus.com/ :

     explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out);
  Effects:
    Constructs an object of class basic_ofstream<charT,traits>, initial-
    izing  the  base  class  with basic_ostream(&sb) and initializing sb
    with basic_filebuf<charT,traits>(), then calls rdbuf()->open(s, mode|out).

It is presumably that "|out" that gcc's libstdc++ is missing. You
should report it to the maintainers of that library in the way
recommended in the gcc info manual (if you want to).

Ian
--
Ian Miller, Dorset, UK



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019