Skip to content

Commit

Permalink
[libc++] Fix error flags and exceptions propagated from input stream …
Browse files Browse the repository at this point in the history
…operations

Summary:
This is a re-application of r357533 and r357531. They had been reverted
because we thought the commits broke the LLDB data formatters, but it
turns out this was because only r357531 had been included in the CI
run.

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.

This effectively implements the wording in p1264r0. It hasn't been voted
into the Standard yet, however there is wide agreement that the fix is
correct and it's just a matter of time before the fix is standardized.

PR21586
PR15949
rdar://problem/15347558

Reviewers: mclow.lists, EricWF

Subscribers: christof, dexonsmith, cfe-commits

Differential Revision: https://reviews.llvm.org/D49863

llvm-svn: 357775
  • Loading branch information
ldionne committed Apr 5, 2019
1 parent bbeca84 commit 396145d
Show file tree
Hide file tree
Showing 42 changed files with 2,480 additions and 533 deletions.
9 changes: 9 additions & 0 deletions libcxx/include/ios
Expand Up @@ -330,6 +330,15 @@ public:
void __set_badbit_and_consider_rethrow();
void __set_failbit_and_consider_rethrow();

_LIBCPP_INLINE_VISIBILITY
void __setstate_nothrow(iostate __state)
{
if (__rdbuf_)
__rdstate_ |= __state;
else
__rdstate_ |= __state | ios_base::badbit;
}

protected:
_LIBCPP_INLINE_VISIBILITY
ios_base() {// purposefully does no initialization
Expand Down

0 comments on commit 396145d

Please sign in to comment.