title: C++ string size_t
body: <p>The following code works as expected i.e., it prints the string in reverse</p>
  
  <pre><code>std::string s("abcd");
  
  for (int i=s.length()-1; i&gt;=0; --i) {
      std::cout &lt;&lt; s[i];
  }
  </code></pre>
  
  <p>However, the following code goes into infinite loop printing junk characters and finally crashes-</p>
  
  <pre><code>std::string s("abcd");
  
  for (std::size_t i=s.length()-1; i&gt;=0; --i) {
      std::cout &lt;&lt; s[i];
  }
  </code></pre>
  
  <p>Why using <code>size_t</code> as type of <code>i</code> crashes the program?</p>
  
  <p>Am using g++ shipped with MinGW on Windows</p>
  
  <pre><code>C:/MinGW/bin/g++ --version
  g++ (GCC) 6.1.0
  </code></pre>