title: Why can't size_t be directly compared with negative int?
body: <p>One bug in my program is caused by directly comparing <code>size_t</code> with <code>int</code>.</p>
  <p>A toy sample code is as follows:</p>
  <pre><code>string s = &quot;AB&quot;;
  cout &lt;&lt; (-1 &lt; 8888888+(int)s.size()) &lt;&lt; endl;
  cout &lt;&lt; (-1 &lt; 8888888+s.size()) &lt;&lt; endl;
  </code></pre>
  <p>The output is:</p>
  <blockquote>
  <p>1</p>
  <p>0</p>
  </blockquote>
  <p>So why can't <code>size_t</code> be directly compared with negative <code>int</code>?</p>