Skip to content

pointer used after 'void operator delete(void*, std::size_t)' in simple_state.hpp #22

@ocroquette

Description

@ocroquette

Switching recently from GCC 11 to 12 (MinGW), we encountered the following new warning:

inlined from 'boost::statechart::detail::reaction_result boost::statechart::simple_state<MostDerived, Context, InnerInitial, historyMode>::react_impl(const event_base_type&, typename Context::inner_context_type::rtti_policy_type::id_type) [with MostDerived = ourstuff::{anonymous}::OurStuff Context = ourstuff::{anonymous}::OurStuff; InnerInitial = boost::mpl::list<mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>; boost::statechart::history_mode historyMode = boost::statechart::has_no_history]' at C:/.../boost-1_80/boost/statechart/simple_state.hpp:489:37:

C:/.../boost-1_80/boost/statechart/detail/counted_base.hpp:80:27: error: pointer used after 'void operator delete(void*, std::size_t)' [-Werror=use-after-free]

   80 |       return --base_type::count_ == 0;

This happens only in the "RelWithDebInfo" CMake configuration.

As a workaround, we patched this file to disable the warning using a #pragma, since warnings are considered as errors in this project.

This is the code producing the warning in context, for reference:

    bool release() const
    {
      BOOST_ASSERT( base_type::count_ > 0 );
      return --base_type::count_ == 0;
    }

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