This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: in_avail() error. Major compliance problem
David Rasmussen <pinkfloydhomer@yahoo.com> writes:
> On Sunday 28 October 2001 01:10, Florian Weimer wrote:
>> David Rasmussen <pinkfloydhomer@yahoo.com> writes:
>> > #include <iostream> int main()
>> > {
>> > std::cout << std::cin.rdbuf()->in_avail() << std::endl;
>> > return 0;
>> > }
>> >
>> > This simple code should write a 0 and exit immediately. This is what
>> > happens with gcc 2.95.3 and the library that comes with that. With gcc
>> > 3.0.2, it is hanging blockingly until enter is pressed, and then writes a
>> > 1.
>>
>> This behavior is probably correct as far as the C++ standard is
>> concerned, I'm afraid.
>
> How do you figure? in_avail shouldn't be blocking according to the
> standard.
Why do you think so? There's no way to implement in_avail() in a
non-blocking manner for line-oriented devices, and it's very hard to
come up with a formal requirement suitable for standardization which
describes non-blocking behavior.
That's why I doubt that the C++ standard mandates non-blocking
behavior, and I was unable to find such a reference in the standard.
> And it shouldn't return 1 always according to the standard.
Does it do that? What happens if you press C-d instead of RET?