diff --git a/libcxx/include/istream b/libcxx/include/istream --- a/libcxx/include/istream +++ b/libcxx/include/istream @@ -1619,7 +1619,7 @@ __is.rdbuf()->sbumpc(); } __x = bitset<_Size>(__str); - if (__c == 0) + if (_Size > 0 && __c == 0) __state |= ios_base::failbit; #ifndef _LIBCPP_NO_EXCEPTIONS } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.operators/stream_in.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.operators/stream_in.pass.cpp --- a/libcxx/test/std/utilities/template.bitset/bitset.operators/stream_in.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.operators/stream_in.pass.cpp @@ -25,6 +25,18 @@ in >> b; assert(b.to_ulong() == 0x5A); } + { + // Make sure that input-streaming an empty bitset does not cause the + // failbit to be set (LWG 3199). + std::istringstream in("01011010"); + std::bitset<0> b; + in >> b; + assert(b.to_string() == ""); + assert(!in.bad()); + assert(!in.fail()); + assert(!in.eof()); + assert(in.good()); + } #ifndef TEST_HAS_NO_EXCEPTIONS { std::stringbuf sb; diff --git a/libcxx/www/upcoming_meeting.html b/libcxx/www/upcoming_meeting.html --- a/libcxx/www/upcoming_meeting.html +++ b/libcxx/www/upcoming_meeting.html @@ -71,7 +71,7 @@ 3191Yesstd::ranges::shuffle synopsis does not match algorithm definitionCologne 3196Yesstd::optional<T> is ill-formed is T is an arrayCologneComplete 3198YesBad constraint on std::span::span()CologneComplete -3199Yesistream >> bitset<0> failsCologne +3199Yesistream >> bitset<0> failsCologneComplete 3202YesP0318R1 was supposed to be revisedCologneComplete 3206Yesyear_month_day conversion to sys_days uses not-existing member functionCologneComplete 3208YesBoolean's expression requirements are ordered inconsistentlyCologneNothing to do @@ -105,7 +105,6 @@
  • 3191 - We don't do ranges yet
  • 3196 - We already do this
  • 3198 - We already do this
  • -
  • 3199 - Louis
  • 3202 - We already do this
  • 3206 - We already do this; added a couple of explicit tests
  • 3208 - Nothing to do; wording cleanup