public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/7424: libstdc++: ifstream::open() does not work on used ifstream objects
@ 2002-07-28  7:09 paolo
  0 siblings, 0 replies; 2+ messages in thread
From: paolo @ 2002-07-28  7:09 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, paolo, rl117

Synopsis: libstdc++: ifstream::open() does not work on used ifstream objects

Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Sun Jul 28 07:09:16 2002
Responsible-Changed-Why:
    Triaged.
State-Changed-From-To: open->closed
State-Changed-By: paolo
State-Changed-When: Sun Jul 28 07:09:16 2002
State-Changed-Why:
    Not a bug. Please see the FAQ, entry 4.4 on reopening
    http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#4_0
    Thanks, Paolo.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7424


^ permalink raw reply	[flat|nested] 2+ messages in thread

* libstdc++/7424: libstdc++: ifstream::open() does not work on used ifstream objects
@ 2002-07-28  6:46 roger
  0 siblings, 0 replies; 2+ messages in thread
From: roger @ 2002-07-28  6:46 UTC (permalink / raw)
  To: gcc-gnats, debian-gcc


>Number:         7424
>Category:       libstdc++
>Synopsis:       libstdc++: ifstream::open() does not work on used ifstream objects
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 28 06:46:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Roger Leigh
>Release:        3.1.1 20020703 (Debian prerelease) (Debian testing/unstable)
>Organization:
N/A
>Environment:
System: Linux whinlatter 2.4.18 #6 Thu Jul 11 11:41:55 BST 2002 i686 unknown
Architecture: i686

	
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: /mnt/data/gcc-3.1/gcc-3.1-3.1.1ds2/src/configure -v --enable-languages=c,c++,java,f77,proto,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/g++-v3-3.1 --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --enable-clocale=gnu --enable-__cxa_atexit --enable-threads=posix --enable-java-gc=boehm --enable-objc-gc i386-linux
>Description:
The following code works with g++-2.95, but not g++-3.0 or g++-3.1
(example).  For the latter two, re-using the same ifstream object
(ifstream::open()) results in failure.  Defining and using a new
ifstream object is OK.

Test output (g++-3.1):
roger@whinlatter:~/cc/16$ ./test2 
Open(1) succeeded
Current file contents:
[file contents]

***EOF***
Unable to open filename for appending.

Test output (6++-2.95):
roger@whinlatter:~/cc/16$ ./test2 
Open(1) succeeded
Current file contents:
[file contents]

***EOF***
Open(2) succeeded

Note the second open fails for g++ 3.1.

I'm willing to provide any additional data you might require.  My
system is Debian GNU/Linux (sid).  As my incoming email is broken
right now (at the ISP), I might not be reachable.  My phone number
is +44 01254 664642 (UK).
>How-To-Repeat:
If lines 16-23 are commented out, it will run successfully (gcc 3.0
and 3.1) otherwise both will fail to reopen the file (but gcc 2.95.2
will succeed).

#include <fstream>
#include <iostream>
using std::cout;
using std::ifstream;

int main()
{
  char* filename = "filename";
  ifstream infile(filename);
  if (!infile)
    {
      cout << "Unable to open " << filename << " for reading.\n";
      return 1;
    }
  cout << "Open(1) succeeded\n";
  if (infile)
    {
      cout << "Current file contents:\n";
      char ch;
      while (infile.get(ch))
	cout << ch;
      cout << "\n***EOF***\n";
    }
  infile.close();

  infile.open(filename);
  if (!infile)
    {
      cout << "Unable to open " << filename << " for appending.\n";
      return 1;
    }
  cout << "Open(2) succeeded\n";
  // read file again
  infile.close();

  return 0;
}
>Fix:
         None, sorry.  I'm only just learning C++, and found this error when I was
	 learning about iostream and file I/O.
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-07-28 14:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-28  7:09 libstdc++/7424: libstdc++: ifstream::open() does not work on used ifstream objects paolo
  -- strict thread matches above, loose matches on Subject: below --
2002-07-28  6:46 roger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).