c++ safeness of code with implicit conversion between signed and unsigned : <p>According to the rules on implicit conversions between signed and unsigned integer types, discussed <a href="https://stackoverflow.com/questions/17832815/c-implicit-conversion-signed-unsigned">here</a> and <a href="https://stackoverflow.com/questions/50605/signed-to-unsigned-conversion-in-c-is-it-always-safe">here</a>, when summing an <code>unsigned int</code> with a <code>int</code>, the signed <code>int</code> is first converted to an <code>unsigned int</code>.</p>

<p>Consider, e.g., the following minimal program</p>

<pre><code>#include &lt;iostream&gt;

int main()
{
   unsigned int n = 2;
   int x = -1;

   std::cout &lt;&lt; n + x &lt;&lt; std::endl;

   return 0;
}
</code></pre>

<p>The output of the program is, nevertheless, 1 as expected: <code>x</code> is converted first to an <code>unsigned int</code>, and the sum with <code>n</code> leads to an integer overflow, giving the "right" answer.</p>

<p>In a code like the previous one, if I know for sure that <code>n + x</code> is positive, can I assume that the sum of <code>unsigned int n</code> and <code>int x</code> gives the expected value?</p>
