Issue 3568: basic_istream_view needs to initialize value_ (original) (raw)
This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++23 status.
3568. basic_istream_view needs to initialize _value_
Section: 25.6.6.2 [range.istream.view] Status: C++23 Submitter: Casey Carter Opened: 2021-06-15 Last modified: 2023-11-22
Priority: Not Prioritized
View all issues with C++23 status.
Discussion:
P2325R3 removes the default member initializers for basic_istream_view's exposition-only _stream_ and _value_ members. Consequently, copying a basic_istream_viewbefore the first call to begin may produce undefined behavior since doing so necessarily copies the uninitialized _value_. We should restore _value_'s default member initializer and remove this particular footgun.
[2021-06-23; Reflector poll]
Set status to Tentatively Ready after seven votes in favour during reflector poll.
[2021-10-14 Approved at October 2021 virtual plenary. Status changed: Voting → WP.]
Proposed resolution:
Wording relative to the post-202106 working draft (as near as possible). This PR is currently being implemented in MSVC.
- Modify 25.6.6.2 [range.istream.view] as indicated:
namespace std::ranges {
[…]
template<movable Val, class CharT, class Traits>
requires default_initializable &&
stream-extractable<Val, CharT, Traits>
class basic_istream_view : public view_interface<basic_istream_view<Val, CharT, Traits>> {
[…]
Val value = Val(); // exposition only
};
}