Loop ignores limits: How can I handle this corrupt c++ program? : <p>When I execute my program it doesn't terminate. I haven't changed anything and it has been working before. There is clearly something wrong but I don't understand what and why.</p>

<p>In the screenshot you can see the line</p>

<pre><code>for ( size_t n = 0; n &lt;= (size_t)maxState; n++ ) nodes.push_back(nullptr);
</code></pre>

<p>You can also see that <code>maxState</code> is -1, so <code>(size_t)maxState</code> should be 0. On the right side of the image you can see the values for n and the size of the <code>nodes</code> vector.</p>

<p><a href="https://i.stack.imgur.com/IaPrO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IaPrO.png" alt="n goes to infitiny"></a></p>

<p>I've taken the screenshot after pausing execution. When I resume it doesn't terminate. I've read some things about heap corruption, but without working solutions. Also I'm not sure if heap corruption is the real cause for this strange effect.</p>

<p>I already tried to clean and rebuild.</p>
