diff --git a/libcxx/test/std/ranges/range.factories/range.istream.view/ctor.pass.cpp b/libcxx/test/std/ranges/range.factories/range.istream.view/ctor.pass.cpp index beeeea4c1bbe1..7e9ec8bf631a8 100644 --- a/libcxx/test/std/ranges/range.factories/range.istream.view/ctor.pass.cpp +++ b/libcxx/test/std/ranges/range.factories/range.istream.view/ctor.pass.cpp @@ -27,6 +27,15 @@ static_assert(std::constructible_from, std::wist static_assert(!std::convertible_to>); #endif +struct NoopExtraction { + int n_; // intentionally doesn't have default member initializer +}; + +template +std::basic_istream& operator>>(std::basic_istream& is, const NoopExtraction&) { + return is; // intentionally doesn't modify the NoopExtraction object +} + template void test() { // test constructor init the stream pointer to the passed one @@ -37,12 +46,18 @@ void test() { assert(*it == 123); } + // LWG 3568. value_ must be initialized for basic_istream_view to be constexpr-constructible + { + static auto fn_local_iss = make_string_stream(""); + [[maybe_unused]] constexpr auto isv = std::views::istream(fn_local_iss); + } + // LWG 3568. basic_istream_view needs to initialize value_ { - auto iss = make_string_stream(""); - std::ranges::basic_istream_view isv{iss}; - auto iter = isv.begin(); - assert(*iter == 0); + auto iss = make_string_stream("123"); + std::ranges::basic_istream_view isv{iss}; + auto it = isv.begin(); + assert((*it).n_ == 0); } }