This is the mail archive of the libstdc++@sources.redhat.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

bug ofstream and ios::trunc


Hi,

Using both gcc-2.95.2/lib/gcc-lib/powerpc-ibm-aix4.3.2.0 and
i386-redhat-linux/egcs-2.91.66 I am seeing that when ios::trunc is
specified in the ofstream constructor mode parameter, no output is ever
generated, as the following small samples illustrate.

/* no_output.cc */
#include <fstream.h>
int main()
{
        ofstream f("blah", ios::trunc);
        f << "hi\n";
        return 0;
}

vs.

/* gives_output.cc */
#include <fstream.h>
int main()
{
        ofstream f("blah");
        f << "hi\n";
        return 0;
}

It seems that ios::out is not added to the ofstream mode flags if trunc
(and presumably other flags) are used for the mode.  This doesn't make much
sense for an ofstream (out by definition), but I am not sure if the
standard says anything about whether this is bad behaviour or not
(emperically, the C++ compilers on at least AIX, Sun, Dynix, HP and NT all
have ofstreams that set ios::out in addition to whatever flags are
specified by the user.)

Peeter


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]