help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Behavior of ifstream::read()


From: Bernd Strieder
Subject: Re: Behavior of ifstream::read()
Date: Mon, 16 Oct 2006 09:33:55 +0200
User-agent: KNode/0.10.1

Hello,

Alex Vinokur wrote:

> This program has different behavior in
> * g++ 3.4.4 (Cygwin)
> * gpp 4.0.1 *Djgpp)
> * Microsoft C++ 13.00.9466

> Output for Microsoft C++
> -------------------
> rdstate() = 0x0; gcount() = 1500
> rdstate() = 0x0; gcount() = 1500
> rdstate() = 0x0; gcount() = 1500
> rdstate() = 0x0; gcount() = 1500
> rdstate() = 0x0; gcount() = 1500
> rdstate() = 0x3; gcount() = 1071
> rdstate() = 0x3
> -------------------

Output for g++ 4.1.0 as delivered with SuSE Linux 10.1

rdstate() = 0x0; gcount() = 1500
rdstate() = 0x0; gcount() = 1500
rdstate() = 0x0; gcount() = 1500
rdstate() = 0x0; gcount() = 1500
rdstate() = 0x0; gcount() = 1500
rdstate() = 0x6; gcount() = 1072
rdstate() = 0x6

So both Microsoft C++ agree on two bits set in the two final rdstate()
calls.

The 1072 instead of 1071 might be due to linefeed in the last line of
in.txt.

This following are two excerpts from the header files of g++-4.1.0:

  enum _Ios_Iostate
    {
      _S_goodbit                = 0,
      _S_badbit                 = 1L << 0,
      _S_eofbit                 = 1L << 1,
      _S_failbit                = 1L << 2,
      _S_ios_iostate_end = 1L << 16
    };

.....

    // 27.4.2.1.3  Type ios_base::iostate
    /**
     *  @brief This is a bitmask type.
     *
     *  @c "_Ios_Iostate" is implementation-defined, but it is valid to
     *  perform bitwise operations on these values and expect the Right
     *  Thing to happen.  Defined objects of type iostate are:
     *  - badbit
     *  - eofbit
     *  - failbit
     *  - goodbit
    */
    typedef _Ios_Iostate iostate;

So the 0x3 vs. 0x6 issue might be due to different coding of the bits.
It should be possible to verify this in the headers delivered with
Micorsoft C++.

Bernd Strieder



reply via email to

[Prev in Thread] Current Thread [Next in Thread]