Skip to content

Commit 47a1376

Browse files
fix the first failure with ptr_ is uninitialized
1 parent fe18363 commit 47a1376

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

libcxx/include/__tree

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,16 +1016,18 @@ public:
10161016

10171017
template <class... _Args>
10181018
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> __emplace_hint_unique(const_iterator __p, _Args&&... __args) {
1019+
(void)__p.__ptr_->__left_;
10191020
return std::__try_key_extraction<key_type>(
10201021
[this, __p](const key_type& __key, _Args&&... __args2) {
10211022
__end_node_pointer __parent;
10221023
__node_base_pointer __dummy;
1024+
(void)__p.__ptr_->__left_;
10231025
__node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __key);
1024-
__node_pointer __r = static_cast<__node_pointer>(__child);
1026+
__node_pointer __r = std::__static_fancy_pointer_cast<__node_pointer>(__child);
10251027
bool __inserted = false;
10261028
if (__child == nullptr) {
10271029
__node_holder __h = __construct_node(std::forward<_Args>(__args2)...);
1028-
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
1030+
__insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__h.get()));
10291031
__r = __h.release();
10301032
__inserted = true;
10311033
}
@@ -1036,9 +1038,9 @@ public:
10361038
__end_node_pointer __parent;
10371039
__node_base_pointer __dummy;
10381040
__node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __h->__get_value());
1039-
__node_pointer __r = static_cast<__node_pointer>(__child);
1041+
__node_pointer __r = std::__static_fancy_pointer_cast<__node_pointer>(__child);
10401042
if (__child == nullptr) {
1041-
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
1043+
__insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__h.get()));
10421044
__r = __h.release();
10431045
}
10441046
return pair<iterator, bool>(iterator(__r), __child == nullptr);
@@ -1873,6 +1875,9 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(
18731875
const_iterator __prior = __hint;
18741876
if (__prior == begin() || value_comp()(*--__prior, __v)) {
18751877
// *prev(__hint) < __v < *__hint
1878+
auto __xx = __hint.__ptr_;
1879+
auto __yy = __xx->__left_;
1880+
(void)( __yy);
18761881
if (__hint.__ptr_->__left_ == nullptr) {
18771882
__parent = __hint.__ptr_;
18781883
return __parent->__left_;

libcxx/test/std/containers/associative/map/map.ops/find.pass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ TEST_CONSTEXPR_CXX26 bool test() {
7979
{
8080
typedef M::iterator R;
8181
V ar[] = {V(5, 5), V(6, 6), V(7, 7), V(8, 8), V(9, 9), V(10, 10), V(11, 11), V(12, 12)};
82+
(void)ar[0].second;
8283
M m(ar, ar + sizeof(ar) / sizeof(ar[0]));
8384
R r = m.find(5);
8485
assert(r == m.begin());

libcxx/test/support/min_allocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ class min_pointer<void, ID> {
212212

213213
template <class T, class ID>
214214
class min_pointer {
215-
T* ptr_;
215+
T* ptr_ {};
216216

217217
TEST_CONSTEXPR_CXX14 explicit min_pointer(T* p) TEST_NOEXCEPT : ptr_(p) {}
218218

0 commit comments

Comments
 (0)