Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<vector>, <string>: Avoid dereferencing null (fancy) pointers when calling _Seek_to/_Unwrapped on or comparing vector and basic_string's iterators #4275

Merged
merged 7 commits into from
Jan 11, 2024
2 changes: 1 addition & 1 deletion stl/inc/vector
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public:
}

_CONSTEXPR20 void _Seek_to(const value_type* _It) noexcept {
_Ptr = _Refancy<_Tptr>(const_cast<value_type*>(_It));
_Ptr = _It == nullptr ? _Tptr() : _Refancy<_Tptr>(const_cast<value_type*>(_It));
CaseyCarter marked this conversation as resolved.
Show resolved Hide resolved
}

_Tptr _Ptr; // pointer to element in vector
Expand Down
8 changes: 0 additions & 8 deletions tests/libcxx/expected_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1002,14 +1002,6 @@ std/containers/sequences/vector.bool/vector_bool.pass.cpp FAIL
std/containers/sequences/vector/iterators.pass.cpp:0 FAIL
std/containers/sequences/vector/iterators.pass.cpp:1 FAIL

# Not analyzed.
# error C4854: binding dereferenced null pointer to reference has undefined behavior
# note: while evaluating constexpr function 'std::_Refancy'
std/containers/sequences/vector/vector.erasure/erase.pass.cpp:0 FAIL
std/containers/sequences/vector/vector.erasure/erase.pass.cpp:1 FAIL
std/containers/sequences/vector/vector.erasure/erase_if.pass.cpp:0 FAIL
std/containers/sequences/vector/vector.erasure/erase_if.pass.cpp:1 FAIL

# Not analyzed. Inspecting shift operators for quoted().
std/input.output/iostream.format/quoted.manip/quoted_traits.compile.pass.cpp FAIL

Expand Down