title: Why did boost regex run out of stack space?
body: <pre><code>#include &lt;boost/regex.hpp&gt;
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  
  using namespace boost;
  static const regex regexp(
          "std::vector&lt;"
              "(std::map&lt;"
                     "(std::pair&lt;((\\w+)(::)?)+, (\\w+)&gt;,?)+"
               "&gt;,?)+"
          "&gt;");
  
  std::string errorMsg =
  "std::vector&lt;"
          "std::map&lt;"
                  "std::pair&lt;Test::Test, int&gt;,"
                  "std::pair&lt;Test::Test, int&gt;,"
                  "std::pair&lt;Test::Test, int&gt;"
          "&gt;,"
          "std::map&lt;"
                  "std::pair&lt;Test::Test, int&gt;,"
                  "std::pair&lt;Test::Test, int&gt;,"
                  "std::pair&lt;Test::Test, int&gt;"
          "&gt;"
  "&gt;";
  int main()
  {
      smatch result;
      if(regex_match(errorMsg, result, regexp))
      {  
          for (unsigned i = 0; i &lt; result.size(); ++i)
          {  
              std::cout &lt;&lt; result[i] &lt;&lt; std::endl;
          }
      }
  
  //    std::cout &lt;&lt; errorMsg &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  
  <p>this produces:</p>
  
  <pre><code>terminate called after throwing an instance of 'boost::exception_detail::clone_impl&lt;boost::exception_detail::error_info_injector&lt;std::runtime_error&gt;
  &gt;'   what():  Ran out of stack space trying to match the regular expression.
  </code></pre>
  
  <p>compiled with</p>
  
  <pre><code>g++ regex.cc -lboost_regex
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>my platform:</p>
  
  <pre><code>g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
  libboost-regex1.42
  Intel(R) Core(TM)2 Quad CPU Q9400 @ 2.66GHz
  So the latest Ubuntu 64 bit
  </code></pre>