This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: libstdc++/4289: ifstream fails to reset on ifstream::close() after EOF encountered.
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, pme at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Subject: Re: libstdc++/4289: ifstream fails to reset on ifstream::close() after EOF encountered.
- From: Josh Martin <Josh dot Martin at abq dot sc dot philips dot com>
- Date: Tue, 18 Sep 2001 18:43:06 -0600 (MDT)
- Reply-To: Josh Martin <Josh dot Martin at abq dot sc dot philips dot com>
> Synopsis: ifstream fails to reset on ifstream::close() after EOF encountered.
>
> State-Changed-From-To: open->closed
> State-Changed-By: pme
> State-Changed-When: Tue Sep 18 16:12:03 2001
> State-Changed-Why:
> Thank you for your bug report.
>
> > upon ifstream::close() and another ifstream::open() (on the
> > same stream, but not neccesarily the same file) the EOF flag
> > and file position are not reset.
>
> As you noted, the C++ standard does not specify that the
> state flags should be cleared when a file is opened. (Yes,
> it sucks.) The library working group has a defect report (#22)
> on their issues list, unfortunately, the proposed resolution
> states that for open() effects, the text "A successful open
> does not change the error state." should be added. Which is
> what currently happens (or rather, doesn't happen).
>
> The workaround you noted, of calling clear() directly, is the
> only thing that can be done.
>
> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=4289&database=gcc
Hi,
Thank you for your attention and feedback on this issue.
I notice that the C++ standard does not specify that any of the state flags
should be cleared upon open, but shouldn't the file position be set back to the
beginning of the stream? Currently, if there is an error, the file position
stays at -1 after an open(). Is this part of the same issue, or is it something
different?
- Josh Martin