title: How does gcc handle -Wtype-limits?
body: <p>I'm testing a small code snippet with <em>gcc 4.4.5</em> and <code>-Wtype-limits</code> option on.</p>
  
  <pre><code>#include &lt;assert.h&gt;
  #include &lt;limits.h&gt;
  #include &lt;stdint.h&gt;
  
  int main(void)
  {
      /* With other values of v, the behavior of the compiler is the same. */
      uint16_t v = 0; 
      assert((unsigned int)INT_MAX &lt; (unsigned int)v); /* l. 7 */
      return 0;
  }
  </code></pre>
  
  <p>Then, the compiler throws me the following warning:</p>
  
  <p><code>main.c:7: warning: comparison is always false due to limited range of data type</code></p>
  
  <p>However, as far as I know, <code>INT_MAX</code> may be equal to <code>+32767</code> (from <em>C11 (n1570), § 5.2.4.2.1 Sizes of integer types <code>&lt;limits.h&gt;</code></em>). In that case, the variable <code>v</code> would be able to hold the value <code>INT_MAX+1</code>, and the expression in <code>assert</code> would be evaluated to <code>1</code>.</p>
  
  <p>Therefore, I can see two issues:</p>
  
  <ul>
  <li>GCC takes in account my architecture, because, in fact, <code>INT_MAX</code> is not equal to <code>+32767</code>. In that case, it would reduce the benefits of <code>-Wtype-limits</code> for me.</li>
  <li>It is a bug. </li>
  </ul>
  
  <p>What it makes me think about the second option is the following code, which doesn't produce any warning with the same options.</p>
  
  <pre><code>#include &lt;assert.h&gt;
  #include &lt;limits.h&gt;
  #include &lt;stdint.h&gt;
  
  int main(void)
  {
      assert((unsigned int)INT_MAX &lt; (unsigned int)UINT16_MAX);
      return 0;
  }
  </code></pre>
  
  <p>So, what is the correct answer?</p>
  
  <p><em>PS:</em> By the way, I have to apologize because of my old version of <em>gcc</em>. Maybe the behavior of the next releases is different.</p>