Skip to content

Null pointer dereference warning #93

@joaquintides

Description

@joaquintides

GCC, -Wnull-dereference, -O1 or higher.

https://godbolt.org/z/TvWaEbvja

#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/identity.hpp>

int main()
{
  using namespace boost::multi_index;
  multi_index_container<
    int,
    indexed_by<
      ordered_unique<identity<int>>
    >
  > c;
  c.insert(0);
  c.insert(1);

  return 0;
}
In file included from /cefs/22/22e6cdc013c8541ce3d1548e_consolidated/compilers_c++_x86_gcc_15.2.0/include/c++/15.2.0/functional:51,
                 from /app/boost/include/boost/multi_index/detail/ord_index_args.hpp:24,
                 from /app/boost/include/boost/multi_index/ordered_index_fwd.hpp:16,
                 from /app/boost/include/boost/multi_index_container_fwd.hpp:19,
                 from /app/boost/include/boost/multi_index_container.hpp:32,
                 from <source>:1:
In member function 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = int]',
    inlined from 'bool boost::multi_index::detail::ordered_index_impl<KeyFromValue, Compare, SuperMeta, TagList, Category, AugmentPolicy>::link_point(key_param_type, link_info&, boost::multi_index::detail::ordered_unique_tag) [with KeyFromValue = boost::multi_index::identity<int>; Compare = std::less<int>; SuperMeta = boost::multi_index::detail::nth_layer<1, int, boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::identity<int> > >, std::allocator<int> >; TagList = boost::mpl::vector0<mpl_::na>; Category = boost::multi_index::detail::ordered_unique_tag; AugmentPolicy = boost::multi_index::detail::null_augment_policy]' at /app/boost/include/boost/multi_index/detail/ord_index_impl.hpp:1179:13,
    inlined from 'boost::multi_index::detail::ordered_index_impl<KeyFromValue, Compare, SuperMeta, TagList, Category, AugmentPolicy>::final_node_type* boost::multi_index::detail::ordered_index_impl<KeyFromValue, Compare, SuperMeta, TagList, Category, AugmentPolicy>::insert_(value_param_type, final_node_type*&, Variant) [with Variant = boost::multi_index::detail::rvalue_tag; KeyFromValue = boost::multi_index::identity<int>; Compare = std::less<int>; SuperMeta = boost::multi_index::detail::nth_layer<1, int, boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::identity<int> > >, std::allocator<int> >; TagList = boost::mpl::vector0<mpl_::na>; Category = boost::multi_index::detail::ordered_unique_tag; AugmentPolicy = boost::multi_index::detail::null_augment_policy]' at /app/boost/include/boost/multi_index/detail/ord_index_impl.hpp:847:19,
    inlined from 'std::pair<typename boost::multi_index::detail::multi_index_base_type<Value, IndexSpecifierList, Allocator>::type::final_node_type*, bool> boost::multi_index::multi_index_container<Value, IndexSpecifierList, Allocator>::insert_(const Value&, Variant) [with Variant = boost::multi_index::detail::rvalue_tag; Value = int; IndexSpecifierList = boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::identity<int> > >; Allocator = std::allocator<int>]' at /app/boost/include/boost/multi_index_container.hpp:694:40,
    inlined from 'std::pair<typename boost::multi_index::detail::multi_index_base_type<Value, IndexSpecifierList, Allocator>::type::final_node_type*, bool> boost::multi_index::multi_index_container<Value, IndexSpecifierList, Allocator>::insert_rv_(const Value&) [with Value = int; IndexSpecifierList = boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::identity<int> > >; Allocator = std::allocator<int>]' at /app/boost/include/boost/multi_index_container.hpp:711:19,
    inlined from 'std::pair<typename boost::multi_index::detail::multi_index_node_type<Value, IndexSpecifierList, Allocator>::type*, bool> boost::multi_index::detail::index_base<Value, IndexSpecifierList, Allocator>::final_insert_rv_(const value_type&) [with Value = int; IndexSpecifierList = boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::identity<int> > >; Allocator = std::allocator<int>]' at /app/boost/include/boost/multi_index/detail/index_base.hpp:230:31,
    inlined from 'std::pair<boost::multi_index::detail::bidir_node_iterator<boost::multi_index::detail::ordered_index_node<AugmentPolicy, typename SuperMeta::type::index_node_type> >, bool> boost::multi_index::detail::ordered_index_impl<KeyFromValue, Compare, SuperMeta, TagList, Category, AugmentPolicy>::insert(value_type&&) [with KeyFromValue = boost::multi_index::identity<int>; Compare = std::less<int>; SuperMeta = boost::multi_index::detail::nth_layer<1, int, boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::identity<int> > >, std::allocator<int> >; TagList = boost::mpl::vector0<mpl_::na>; Category = boost::multi_index::detail::ordered_unique_tag; AugmentPolicy = boost::multi_index::detail::null_augment_policy]' at /app/boost/include/boost/multi_index/detail/ord_index_impl.hpp:316:62:
/cefs/22/22e6cdc013c8541ce3d1548e_consolidated/compilers_c++_x86_gcc_15.2.0/include/c++/15.2.0/bits/stl_function.h:405:20: error: potential null pointer dereference [-Werror=null-dereference]
  405 |       { return __x < __y; }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions