Compare commits

...

13 Commits

Author SHA1 Message Date
joaquintides 907c890f6e suppressed more null-dereference warnings 2026-04-02 18:42:01 +02:00
joaquintides 008f6a65fc suppressed more null-dereference warnings 2026-04-01 10:09:07 +02:00
joaquintides 52ccca406f fixed assumption 2026-04-01 10:01:10 +02:00
joaquintides 0e4d78896d suppressed more null-dereference warnings 2026-04-01 09:49:45 +02:00
joaquintides 77258d7835 suppressed more null-dereference warnings 2026-04-01 09:30:24 +02:00
joaquintides e02bbcd981 fixed assumption 2026-03-31 19:08:03 +02:00
joaquintides 1ad1fb1ed3 suppressed more null-dereference warnings 2026-03-31 19:02:29 +02:00
joaquintides 8bbf861f01 suppressed more null-dereference warnings 2026-03-31 09:11:21 +02:00
joaquintides 15e7fa99bc suppressed more null-dereference warnings 2026-03-30 18:48:30 +02:00
joaquintides 07db67c544 suppressed more null-dereference warnings 2026-03-30 13:25:44 +02:00
joaquintides ab474ce2af suppressed null-dereference warnings 2026-03-30 13:13:58 +02:00
joaquintides 7ac7bb3954 fixed toolset name 2026-03-30 12:46:47 +02:00
joaquintides 0ba734fe70 enabled -Werror=null-dereference 2026-03-30 12:42:26 +02:00
8 changed files with 73 additions and 8 deletions
@@ -0,0 +1,44 @@
/* Copyright 2003-2026 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/multi_index for library home page.
*/
#ifndef BOOST_MULTI_INDEX_DETAIL_ASSUME_HPP
#define BOOST_MULTI_INDEX_DETAIL_ASSUME_HPP
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/assert.hpp>
#ifdef __has_builtin
#define BOOST_MULTI_INDEX_HAS_BUILTIN(x) __has_builtin(x)
#else
#define BOOST_MULTI_INDEX_HAS_BUILTIN(x) 0
#endif
#if !defined(NDEBUG)
#define BOOST_MULTI_INDEX_ASSUME(cond) BOOST_ASSERT(cond)
#elif BOOST_MULTI_INDEX_HAS_BUILTIN(__builtin_assume)
#define BOOST_MULTI_INDEX_ASSUME(cond) __builtin_assume(cond)
#elif defined(__GNUC__) || \
BOOST_MULTI_INDEX_HAS_BUILTIN(__builtin_unreachable)
#define BOOST_MULTI_INDEX_ASSUME(cond) \
do{ \
if(!(cond))__builtin_unreachable(); \
}while(0)
#elif defined(_MSC_VER)
#define BOOST_MULTI_INDEX_ASSUME(cond) __assume(cond)
#else
#define BOOST_MULTI_INDEX_ASSUME(cond) \
do{ \
static_cast<void>(false&&(cond)); \
}while(0)
#endif
#endif
@@ -1,4 +1,4 @@
/* Copyright 2003-2025 Joaquin M Lopez Munoz.
/* Copyright 2003-2026 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
@@ -15,6 +15,7 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/core/allocator_access.hpp>
#include <boost/multi_index/detail/assume.hpp>
#include <boost/multi_index/detail/raw_ptr.hpp>
#include <utility>
@@ -263,6 +264,7 @@ struct hashed_index_node_alg<Node,hashed_unique_tag>
x->prior()=buc->prior()->prior();
x->next()=base_pointer_from(buc->prior());
buc->prior()=x;
BOOST_MULTI_INDEX_ASSUME(x->next()!=base_pointer(0));
x->next()->prior()=x;
}
}
@@ -404,12 +406,14 @@ struct hashed_index_node_alg<Node,hashed_non_unique_tag>
x->prior()=buc->prior()->prior();
x->next()=base_pointer_from(buc->prior());
buc->prior()=x;
BOOST_MULTI_INDEX_ASSUME(pointer_from(x->next())!=pointer(0));
x->next()->prior()=x;
}
}
static void link(pointer x,pointer first,pointer last)
{
BOOST_MULTI_INDEX_ASSUME(x!=pointer(0)&&first!=pointer(0));
x->prior()=first->prior();
x->next()=base_pointer_from(first);
if(is_first_of_bucket(first)){
@@ -429,6 +433,7 @@ struct hashed_index_node_alg<Node,hashed_non_unique_tag>
else{
pointer second=pointer_from(first->next()),
lastbutone=last->prior();
BOOST_MULTI_INDEX_ASSUME(second!=pointer(0));
second->prior()=first;
first->prior()=last;
lastbutone->next()=base_pointer_from(x);
@@ -655,8 +660,9 @@ private:
static void unlink_last_but_one_of_group(pointer x,Assigner& assign)
{
pointer first=pointer_from(x->next()),
second=pointer_from(first->next()),
last=second->prior();
second=pointer_from(first->next());
BOOST_MULTI_INDEX_ASSUME(second!=pointer(0));
pointer last=second->prior();
if(second==x){
assign(last->prior(),first);
assign(first->next(),base_pointer_from(last));
@@ -1,4 +1,4 @@
/* Copyright 2003-2025 Joaquin M Lopez Munoz.
/* Copyright 2003-2026 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
@@ -49,6 +49,7 @@
#include <boost/core/ref.hpp>
#include <boost/mp11/utility.hpp>
#include <boost/multi_index/detail/adl_swap.hpp>
#include <boost/multi_index/detail/assume.hpp>
#include <boost/multi_index/detail/bidir_node_iterator.hpp>
#include <boost/multi_index/detail/do_not_copy_elements_tag.hpp>
#include <boost/multi_index/detail/index_node_base.hpp>
@@ -1164,6 +1165,7 @@ private:
else index_node_type::decrement(yy);
}
BOOST_MULTI_INDEX_ASSUME(yy!=0);
if(comp_(key(yy->value()),k)){
inf.side=c?to_left:to_right;
inf.pos=y->impl();
@@ -1218,6 +1220,7 @@ private:
else return link_point(k,inf,ordered_unique_tag());
}
else if(position==header()){
BOOST_MULTI_INDEX_ASSUME(rightmost()!=0);
if(comp_(key(rightmost()->value()),k)){
inf.side=to_right;
inf.pos=rightmost()->impl();
@@ -1257,6 +1260,7 @@ private:
else return lower_link_point(k,inf,ordered_non_unique_tag());
}
else if(position==header()){
BOOST_MULTI_INDEX_ASSUME(rightmost()!=0);
if(!comp_(k,key(rightmost()->value()))){
inf.side=to_right;
inf.pos=rightmost()->impl();
@@ -1,4 +1,4 @@
/* Copyright 2003-2025 Joaquin M Lopez Munoz.
/* Copyright 2003-2026 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
@@ -43,6 +43,7 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/core/allocator_access.hpp>
#include <cstddef>
#include <boost/multi_index/detail/assume.hpp>
#include <boost/multi_index/detail/raw_ptr.hpp>
#if !defined(BOOST_MULTI_INDEX_DISABLE_COMPRESSED_ORDERED_INDEX_NODES)
@@ -269,6 +270,7 @@ public:
}
else{
pointer y=x->parent();
BOOST_MULTI_INDEX_ASSUME(y!=pointer(0));
while(x==y->right()){
x=y;
y=y->parent();
@@ -279,6 +281,7 @@ public:
static void decrement(pointer& x)
{
BOOST_MULTI_INDEX_ASSUME(x->color()!=red||x->parent()!=pointer(0));
if(x->color()==red&&x->parent()->parent()==x){
x=x->right();
}
@@ -1,4 +1,4 @@
/* Copyright 2003-2025 Joaquin M Lopez Munoz.
/* Copyright 2003-2026 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
@@ -17,6 +17,7 @@
#include <boost/core/allocator_access.hpp>
#include <algorithm>
#include <boost/core/noncopyable.hpp>
#include <boost/multi_index/detail/assume.hpp>
#include <boost/multi_index/detail/auto_space.hpp>
#include <boost/multi_index/detail/rnd_index_node.hpp>
@@ -87,6 +88,7 @@ public:
*(end()+1)=*end();
(*(end()+1))->up()=end()+1;
*end()=x;
BOOST_MULTI_INDEX_ASSUME(*end()!=value_type(0));
(*end())->up()=end();
++size_;
}
@@ -22,6 +22,7 @@
#include <boost/limits.hpp>
#include <boost/mp11/utility.hpp>
#include <boost/multi_index/detail/adl_swap.hpp>
#include <boost/multi_index/detail/assume.hpp>
#include <boost/multi_index/detail/auto_space.hpp>
#include <boost/multi_index/detail/bucket_array.hpp>
#include <boost/multi_index/detail/do_not_copy_elements_tag.hpp>
@@ -1458,6 +1459,7 @@ private:
node_impl_pointer x=end_->prior();
/* only this can possibly throw */
BOOST_MULTI_INDEX_ASSUME(index_node_type::from_impl(x)!=0);
std::size_t h=hash_(key(index_node_type::from_impl(x)->value()));
hashes.data()[i]=h;
@@ -1511,6 +1513,7 @@ private:
if(x==end_)break;
/* only this can possibly throw */
BOOST_MULTI_INDEX_ASSUME(index_node_type::from_impl(x)!=0);
std::size_t h=hash_(key(index_node_type::from_impl(x)->value()));
hashes.data()[i]=h;
@@ -1,4 +1,4 @@
/* Copyright 2003-2025 Joaquin M Lopez Munoz.
/* Copyright 2003-2026 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
@@ -21,6 +21,7 @@
#include <boost/core/allocator_access.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <boost/mp11/function.hpp>
#include <boost/multi_index/detail/assume.hpp>
#include <boost/multi_index/detail/do_not_copy_elements_tag.hpp>
#include <boost/multi_index/detail/index_node_base.hpp>
#include <boost/multi_index/detail/node_handle.hpp>
@@ -1117,6 +1118,7 @@ private:
for(Iterator it=first;it!=last;++it,++pp){
*pp=static_cast<index_node_type*>(it.get_node());
BOOST_MULTI_INDEX_ASSUME(pp!=0);
(*pp)->up()=pp;
}
}
+2 -1
View File
@@ -1,6 +1,6 @@
# Boost.MultiIndex tests Jamfile
#
# Copyright 2003-2025 Joaquín M López Muñoz.
# Copyright 2003-2026 Joaquín M López Muñoz.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
@@ -37,6 +37,7 @@ project
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
<toolset>msvc:<define>_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
<toolset>msvc:<cxxflags>/wd4494
<toolset>gcc:<cxxflags>-Werror=null-dereference
;
obj boost_multi_index_key_supported : check_bmi_key_supported.cpp ;