Boost C++ Libraries: Ticket #11679: boost::polygon::connectivity_extraction<int>::extract crashes when no polygons were inserted https://svn.boost.org/trac10/ticket/11679 <p> steps to reproduce: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/polygon/polygon.hpp&gt;</span><span class="cp"></span> <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span> <span class="n">boost</span><span class="o">::</span><span class="n">polygon</span><span class="o">::</span><span class="n">connectivity_extraction</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span> <span class="n">ce</span><span class="p">;</span> <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">set</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span> <span class="o">&gt;</span> <span class="n">graph</span><span class="p">;</span> <span class="n">ce</span><span class="p">.</span><span class="n">extract</span><span class="p">(</span><span class="n">graph</span><span class="p">);</span> <span class="c1">// causes access violation</span> <span class="p">}</span> </pre></div></div><p> The debugger indicates an access violation in </p> <div class="wiki-code"><div class="code"><pre> <span class="k">template</span> <span class="o">&lt;</span><span class="k">typename</span> <span class="n">iT</span><span class="o">&gt;</span> <span class="k">static</span> <span class="kr">inline</span> <span class="kt">void</span> <span class="n">compute_histogram_in_y</span><span class="p">(</span><span class="n">iT</span> <span class="n">begin</span><span class="p">,</span> <span class="n">iT</span> <span class="n">end</span><span class="p">,</span> <span class="n">std</span><span class="o">::</span><span class="kt">size_t</span> <span class="n">size</span><span class="p">,</span> <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">pair</span><span class="o">&lt;</span><span class="n">Unit</span><span class="p">,</span> <span class="n">std</span><span class="o">::</span><span class="n">pair</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="kt">size_t</span><span class="p">,</span> <span class="n">std</span><span class="o">::</span><span class="kt">size_t</span><span class="o">&gt;</span> <span class="o">&gt;</span> <span class="o">&gt;&amp;</span> <span class="n">histogram</span><span class="p">);</span> </pre></div></div><p> Apparently, the original coder assumed (incorrectly?) that the given size != 0. </p> <p> a simple 'if' would probably resolve this I do in my client code as well. I just wonder what the best level would be to introduce this if: </p> <ul><li>connectivity_extraction::extract </li><li>arbitrary_connectivity_extraction::execute </li><li>or better in boost::polygon::line_intersection&lt;T&gt;::validate_scan ? </li></ul> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11679 Trac 1.4.3