Boost C++ Libraries: Ticket #13088: Boost::binomial_heap Merge memcheck error https://svn.boost.org/trac10/ticket/13088 <p> Binomial heap merge routine reads from uninitialized memory in the attached example. </p> <pre class="wiki">#include "boost/heap/binomial_heap.hpp" typedef boost::heap::binomial_heap&lt;int&gt; Heap; int main(int /*argc*/, char* /*argv*/[]) { Heap heap0; size_t heap0_size = 3; size_t max_range = 100; for (size_t ix = 0; ix &lt; heap0_size; ++ix) { heap0.push(rand() % max_range); } Heap heap1; size_t heap1_size = 5; for (size_t ix = 0; ix &lt; heap1_size; ++ix) { heap1.push(rand() % max_range); } heap0.merge(heap1); } </pre><p> I believe the error stems from the case identified by line 699 in binomial_heap.hpp. If the last node of trees is erased in this line (as is the case in this example), this_iterator now points to trees.end(). However, for this case, it will follow the goto statement and start another iteration which will cause the function to again read from this_iterator. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13088 Trac 1.4.3 jun.kudo@… Tue, 20 Jun 2017 17:47:20 GMT attachment set https://svn.boost.org/trac10/ticket/13088 https://svn.boost.org/trac10/ticket/13088 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">main3.cpp</span> </li> </ul> Ticket anonymous Tue, 20 Jun 2017 17:48:55 GMT attachment set https://svn.boost.org/trac10/ticket/13088 https://svn.boost.org/trac10/ticket/13088 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">valgrind.txt</span> </li> </ul> Ticket