title: Why compiler is not giving error when signed value is assigned to unsigned integer? - C++
body: <p>I know <em>unsigned int</em> can't hold negative values. But the following code compiles without any errors/warnings.</p>
  
  <pre><code>unsigned int a = -10;
  </code></pre>
  
  <p>When I print the variable <em>a</em>, I get a wrong value printed. If unsigned variables can't hold signed values, why do compilers allow them to compile without giving any error/warning?</p>
  
  <p>Any thoughts?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Compiler : VC++ compiler</p>
  
  <p><strong>Solution</strong></p>
  
  <p>Need to use the warning level 4.</p>