This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
3972. Issues withjoin_with_view::iterator
's iter_swap
Section: 25.7.15.3 [range.join.with.iterator] Status: New Submitter: Hewill Kang Opened: 2023-09-04 Last modified: 2023-11-03
Priority: 2
View other active issues in [range.join.with.iterator].
View all other issues in [range.join.with.iterator].
View all issues with New status.
Discussion:
The iter_swap
customization for join_with_view::iterator
allows swapping iterators with different element types, potentially leading to unsafe behavior, for example:
vector<vector<string>> x{{"a"}, {"b"}, {"c"}}; vector<string_view> y{"-"}; auto r = x | views::join_with(y); auto i = r.begin(); auto j = ranges::next(i); ranges::iter_swap(j, i); for (auto&& elem : r) cout << elem << " "; // AddressSanitizer: stack-use-after-return on address
The above swaps two iterators whose reference are string_view&
and string&
respectively, which ultimately results in string_view
being referenced to a local variable and left dangling.
[2023-11-02; Reflector poll]
Set priority to 2 after reflector poll.
Proposed resolution:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4