[heap] Singular handle issue with MSVC iterator debug facilities

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

[heap] Singular handle issue with MSVC iterator debug facilities

Boost - Users mailing list

Using VS2017 and Boost 1.64, I'm compiling a program which uses

In debug configuration (with default _ITERATOR_DEBUG_LEVEL),
I'm observing issues at run-time when a handle of item on the heap is
compared against default-constructed instance of handle_type.

BTW, the handle_type compiled in is based on std::list::iterator
as defined in boost::heap::detail::priority_queue_mutable_wrapper.

The issue is that MSVC iterator debug facilities break execution with

File: c:\program files (x86)\microsoft visual
Line: 290
Expression: list iterators incompatible

AFAIU, handle_type{}; seems to yield handle h object wrapping singular iterator.

Below, minimal example to reproduces the problem is included.

While debugging the sample, Visual C++ debugger does not show the iterator
wrapped by the handle as default-constructed with null node pointer.
Instead, it displays garbage: ((???, ???), ???)

// ------------------------------------------------------------------
#include <cstdint>
#include <functional>
#include <boost/heap/d_ary_heap.hpp>

using NodeID = std::uint32_t;
using EdgeWeight = std::int32_t;

using HeapData = std::pair<EdgeWeight, NodeID>;
using HeapContainer = boost::heap::d_ary_heap<
using HandleType = HeapContainer::handle_type;

int main()
    HeapContainer heap;
    auto const handle = heap.push(std::make_pair(100, 1));
    handle == HandleType{}; // _DEBUG_ERROR("list iterators incompatible");

    return 0;
// ------------------------------------------------------------------

Is this a known MSVC drawback while working with boost::heap::d_ary_heap
or above the handle_type is actually misused?

Best regards,
Mateusz Loskot, http://mateusz.loskot.net
Boost-users mailing list
[hidden email]