Skip to content

test_limit_reference: clang-tidy complains about possible use of freed memory #44

Closed
@murraycu

Description

@murraycu

I can't remember if we've noticed this before, but it might need investigation:

clang-tidy-9 -p=/home/murrayc/checkout/github/libsigcplusplus/cmake_build /home/murrayc/checkout/github/libsigcplusplus/tests/test_limit_reference.cc
/home/murrayc/checkout/github/libsigcplusplus/sigc++/limit_reference.h:113:35: warning: Use of memory after it is freed [clang-analyzer-cplusplus.NewDelete]
inline T_type& invoke() const { return invoked; }
^
/home/murrayc/checkout/github/libsigcplusplus/tests/test_limit_reference.cc:37:7: note: Assuming the condition is false
if (!util->check_command_args(argc, argv))
^
/home/murrayc/checkout/github/libsigcplusplus/tests/test_limit_reference.cc:37:3: note: Taking false branch
if (!util->check_command_args(argc, argv))
^
/home/murrayc/checkout/github/libsigcplusplus/tests/test_limit_reference.cc:40:19: note: Memory is allocated
auto instance = new Derived();
^
/home/murrayc/checkout/github/libsigcplusplus/tests/test_limit_reference.cc:53:3: note: Memory is released
delete instance;
^
/home/murrayc/checkout/github/libsigcplusplus/tests/test_limit_reference.cc:56:3: note: Calling 'bind_functor::operator()'
param();
^
/home/murrayc/checkout/github/libsigcplusplus/sigc++/adaptors/bind.h:190:26: note: Calling 'tuple_transform_each<internal::TransformEachInvoker, std::tuple<sigc::bound_argument<std::reference_wrapper<(anonymous namespace)::Derived> > > &>'
const auto t_bound = internal::tuple_transform_eachinternal::TransformEachInvoker(bound_);
^
/home/murrayc/checkout/github/libsigcplusplus/sigc++/tuple-utils/tuple_transform_each.h:103:10: note: Calling 'tuple_transform_each_impl::tuple_transform_each'
return detail::tuple_transform_each_impl<T_transformer, size>::tuple_transform_each(
^
/home/murrayc/checkout/github/libsigcplusplus/sigc++/tuple-utils/tuple_transform_each.h:39:19: note: 1 is not equal to 0
if constexpr (size_from_index == 0)
^
/home/murrayc/checkout/github/libsigcplusplus/sigc++/tuple-utils/tuple_transform_each.h:39:5: note: Taking false branch
if constexpr (size_from_index == 0)
^
/home/murrayc/checkout/github/libsigcplusplus/sigc++/tuple-utils/tuple_transform_each.h:63:9: note: Calling 'TransformEachInvoker::transform'
T_transformer<from_element_type>::transform(std::get(t_original)));
^
/home/murrayc/checkout/github/libsigcplusplus/sigc++/adaptors/bind.h:110:74: note: Calling 'bound_argument::invoke'
constexpr static decltype(auto) transform(T_element& element) { return element.invoke(); }
^
/home/murrayc/checkout/github/libsigcplusplus/sigc++/adaptors/bound_argument.h:96:39: note: Calling 'limit_reference::invoke'
inline T_wrapped& invoke() { return visited_.invoke(); }
^
/home/murrayc/checkout/github/libsigcplusplus/sigc++/limit_reference.h:113:35: note: Use of memory after it is freed
inline T_type& invoke() const { return invoked; }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions