Both Suse 9.3 (gcc 3.3.5/x86_64) and 10.0 (gcc 4.0.2/x86_64) exhibit this same
problem -- open an fstream with out|in will not actually create the file. 
Strace shows that O_CREAT is not passed to open() when out|in is used, but is
if just 'out' is used.  This is a rehash of bug #5629 which is claimed to be
fixed but apparently isn't.

#include <fstream>

using std::fstream;

int main(int argc,char **argv)
{
    fstream f;

    f.open("test-1",fstream::binary | fstream::out );
    f.close();

    f.open("test-2",fstream::binary | fstream::out | fstream::in );
    f.close();

    return 0;
}


[EMAIL PROTECTED]:~/src$ strace ./test 2>&1 | grep open | grep test
open("test-1", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
open("test-2", O_RDWR)                  = -1 ENOENT (No such file or directory)


-- 
           Summary: fstream class is unable to create file in a read/write
                    mode
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ssmith at cemaphore dot com
 GCC build triplet: x86_64-suse-linux
  GCC host triplet: x86_64-suse-linux
GCC target triplet: x86_64-suse-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24320

Reply via email to