This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


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

Re: libstdc++/4289: ifstream fails to reset on ifstream::close() after EOF encountered.


> 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


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