[istream] Fix error flags and exceptions propagated from input stream operations
AcceptedPublic

Authored by ldionne on Jul 26 2018, 9:25 AM.

Details

Summary

Before this patch, we would only ever throw an exception if the badbit
was set on the stream. The Standard is currently very unclear on how
exceptions should be propagated and what error flags should be set by
the input stream operations. This commit changes libc++ to behave under
a different (but valid) interpretation of the Standard. This interpretation
of the Standard matches what other implementations are doing.

I will submit a paper in San Diego to clarify the Standard such that the
interpretation used in this commit (and other implementations) is the only
possible one.

https://bugs.llvm.org/show_bug.cgi?id=21586
https://bugs.llvm.org/show_bug.cgi?id=15949
rdar://problem/15347558

ldionne created this revision.Jul 26 2018, 9:25 AM

This is a very tricky change since it touches all the input stream operations, both formatted and unformatted. However, I think it's an important change as it fixes extremely broken behavior. The paper I'm working on to fix this in the Standard is https://github.com/ldionne/wg21/blob/4d963b488182b96479636c252695542671fd5e41/generated/drxxxx.pdf. Perhaps we should wait for the paper to make its way through the Standard before committing this, but in any case the new behavior of libc++ should now match that of libstdc++ and MSVC (couldn't test with those libraries, though).

lichray accepted this revision.Thu, Nov 8, 11:20 AM
lichray added a subscriber: lichray.
lichray added inline comments.
libcxx/include/istream
365

I like auto just FYI :)

1005

LOL

This revision is now accepted and ready to land.Thu, Nov 8, 11:20 AM