https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86130

--- Comment #16 from Paul Sanders <p.sanders at alpinesoft dot co.uk> ---
Interesting, I can see why you don't want to change the behaviour again.  It's
just a shame it ever did anything other than SEGFAULT in the first place but as
you point out, it's been the way it is for a long time now and changing it
would be foolhardy.

Just to finish off (I see that the decision is made):

> this code has been present since r53839 in 2002 ... [and] it's far too late 
> to just turn this into a segfault because somebody on stackoverflow found it 
> surprising and doesn't know how to check iostreams for errors.

I'm sure myself and the OP aren't the only ones ever to have been 'surprised'
by this, and more will follow.  I will update my answer at SO to explain what
is really happening and how to fix it (the original code wasn't my own).  

Thank you for taking the time to lay things out for me, I learnt a lot here,
even if I still don't like the way ostream behaves under these circumstances. 
It seems to me that badbit's job is to reflect whether or not the stream is in
a usable state, and not get set just because something strange has been passed
to the stream which does it no actual harm.  It (badbit) just got abused back
in 2002, so to speak, and now we're stuck with it.

And finally, I owe you an apology for ever thinking that ostream would silently
terminate your program like that; I posted one on SO. I hope it does some good,
I don't set out to aggravate you guys.

Reply via email to