goodbit and zero as ios_base::iostate values
gp
cpp_lists@libero.it
Wed Nov 6 10:12:00 GMT 2002
> Hello!
Hi! :-)
[...]
> it contains the line
>
> ios_base::iostate err = 0;
That's not required to work, so there's an error in the standard.
> which doesn't compile with g++ 3.2 because it says:
>
> invalid conversion from `int' to `std::_Ios_Iostate'
With the libstdc++ implementation the error message is correct.
> Also [lib.istream.formatted.arithmetic] contains a code fragment where
>
> iostate err = 0;
>
> ios_base::iostate is of [lib.bitmask.types] bitmask type and it seems to
me
> that the Standard doesn't there say anything about from int to bitmask
> conversion nor about initialization from int.
You are correct. They should have written
ios_base::iostate err= ios_base::goodbit;
> However, [lib.ios::iostate] first tells about the three elements
> badbit, eofbit and failbit, and then mentions that:
>
> Type iostate also defines the constant:
> - goodbit, the value zero.
I think a DR is in order here. Actually what is meant is "iostate()", i.e.
the value obtained with value-initialization. See 5.2.3/2 (with the
corrections of core issue 178) and, for the case where iostate is a bitset,
23.3.5.1
Why don't you submit it to comp.std.c++?
>
> I cannot judge from these two code excerpts and the vague mention of
> zero value, whether the libstdc++ implementation is conformant or not.
As far as iostate is concerned it is conforming, as you may see from
17.3.2.1.2.
Genny.
More information about the Libstdc++
mailing list