This is the mail archive of the libstdc++@gcc.gnu.org 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]

Re: [BUG] GCC 3.0.1 fstream problems


The GNATS case number for this is libstdc++/4289

It turns out that this is actually a "bug" in the library specification. Here is
an excerpt from http://www.cantrip.org/draft-bugs.txt :

***

Nathan's Issues for ISO 14882 Library Clauses   DRAFT 98-08-13
by Nathan C. Myers  ncm@nospam.cantrip.org

.
.
.

--------------------------------------------------------------------------
9. 27.8.1.7 [lib.ifstream.members] member open vs. flags

The description of basic_istream<>::open leaves unanswered questions
about how it responds to or changes flags in the error status for the
stream.  A strict reading indicates that it ignores the bits and does
not change them, which confuses users who do not expect eofbit and
failbit to remain set after a successful open.  There are three
reasonable resolutions: 1) status quo  2) fail if fail(), ignore
eofbit  3) clear failbit and eofbit on call to open().

Proposed resolution:
In 27.8.1.7 [lib.ifstream.members], _and_ in 27.8.1.10
[lib.ofstream.members], under open(), one of

  A. no change
  B. Prepend to Effects: "If fail(), returns.  Otherwise"...
  C. Prepend to Effects: "Call clear(); then," ...


--------------------------------------------------------------------------
10. 27.8.1.10 [lib.ofstream.members] member open vs. flags

  (same as issue 9, respective.)

***

Personally, I am a fan of proposal C, as this is how gcc responded prior to 3.0, 
but I suppose that this should probably be discussed before a resolution is 
decided.

 - Josh Martin
  
> There seems to be a problem with the ifstream object that started with gcc 
3.0.
> If you open an ifstream, read in part of a file, close the stream, and then 
> re-open the stream for the same or a different file, the file position 
> (ifstream::tellg()) and the eof flag (ifstream::eof()) are correctly reset. 
> However, if, during the opening and reading in of the file, you encounter an 
> EOF, the file position and eof flag and not reset upon the close() and 
> subsequent open(). A call to ifstream::clear() in the stream is required to 
get 
> the stream to reset. 
> 
> A simple test case is given with important information output via cout at 
> critical moments.
> 
>  - Josh
> 
> The compile command line and output are as follows, and the preprocessed file 
> (test.ii) is attached.
> 
>  ---
> 
> g++ -v -save-temps -Wall -Wl,+vallcompatwarnings -otest test.cpp
> 
> Reading specs from /usr/local/lib/gcc-lib/hppa2.0n-hp-hpux11.00/3.0.1/specs
> Configured with: /usr/local/build/gcc-3.0.1/configure 
> --build=hppa2.0n-hp-hpux11.00 --host=hppa2.0n-hp-hpux11.00 --with-gnu-as 
> --with-as=/usr/local/bin/as
> Thread model: single
> gcc version 3.0.1
>  /usr/local/lib/gcc-lib/hppa2.0n-hp-hpux11.00/3.0.1/cpp0 -lang-c++ 
-D__GNUG__=3 
> -D__GXX_DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -D__GNUC__=3 
> -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=1 -Dhppa -Dhp9000s800 -D__hp9000s800 
> -Dhp9k8 -DPWB -Dhpux -Dunix -D__hppa__ -D__hp9000s800__ -D__hp9000s800 
> -D__hp9k8__ -D__PWB__ -D__hpux__ -D__unix__ -D__hppa -D__hp9000s800 -D__hp9k8 
> -D__PWB -D__hpux -D__unix -Asystem=unix -Asystem=hpux -Acpu=hppa 
-Amachine=hppa 
> -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Wall -D_HPUX_SOURCE -D_HIUX_SOURCE 
> -D__STDC_EXT__ -D_PA_RISC1_1 -D__hp9000s700 test.cpp test.ii
> GNU CPP version 3.0.1 (cpplib) (hppa)
> #include "..." search starts here:
> #include <...> search starts here:
>  /usr/local/include/g++-v3
>  /usr/local/include/g++-v3/hppa2.0n-hp-hpux11.00
>  /usr/local/include/g++-v3/backward
>  /usr/local/include
>  /usr/local/lib/gcc-lib/hppa2.0n-hp-hpux11.00/3.0.1/include
>  /usr/local/hppa2.0n-hp-hpux11.00/include
>  /usr/include
> End of search list.
>  /usr/local/lib/gcc-lib/hppa2.0n-hp-hpux11.00/3.0.1/cc1plus -fpreprocessed 
> test.ii -quiet -dumpbase test.cpp -Wall -version -o test.s
> GNU CPP version 3.0.1 (cpplib) (hppa)
> GNU C++ version 3.0.1 (hppa2.0n-hp-hpux11.00)
> 	compiled by GNU C version 3.0.1.
>  /usr/local/bin/as --traditional-format -o test.o test.s
>  /usr/local/lib/gcc-lib/hppa2.0n-hp-hpux11.00/3.0.1/collect2 -L/lib/pa1.1 
> -L/usr/lib/pa1.1 -z -u main -otest /usr/lib/crt0.o -L/usr/local/lib 
> -L/home/jdmartin/local/lib 
-L/usr/local/lib/gcc-lib/hppa2.0n-hp-hpux11.00/3.0.1 
> -L/usr/ccs/bin -L/usr/ccs/lib -L/opt/langtools/lib 
> -L/usr/local/lib/gcc-lib/hppa2.0n-hp-hpux11.00/3.0.1/../../.. 
> +vallcompatwarnings test.o -lstdc++ -lm -lgcc -lc -lgcc


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