Boost C++ Libraries: Ticket #331: spirit: run-time error https://svn.boost.org/trac10/ticket/331 <pre class="wiki">I am using the Spirit library v1.8.1, part of Boost 1.32. Here is a test case which fails at run-time: I get a VC++ Debug Library Error in file core\non-terminal\impl\rule.ipp at line 173. My compiler is VC++ 7.1 on Windows XP SP2. In particular I get a Run-Time Check Failure #2: Stack around the variable 'context-wrap' was corrupted. Any idea about what can be the problem? Please note that with the following I don't get any error: definition(const JSIGrammar&amp; self) { Rule_T pp_token = real_p r = ch_p('#') &gt;&gt; str_p("line") &gt;&gt; +(pp_token); } struct JSIGrammar : public grammar&lt;JSIGrammar&gt; { template &lt;typename ScannerT&gt; struct definition { typedef rule&lt;ScannerT&gt; Rule_T; definition(const JSIGrammar&amp; self) { Rule_T pp_number = real_p; Rule_T pp_token = pp_number; r = ch_p('#') &gt;&gt; str_p("line") &gt;&gt; +(pp_token); } const Rule_T&amp; start() const { return r; } Rule_T r; }; }; int main(int argc, char* argv[]) { string str; { ifstream in(argv[1]); ostringstream out; out &lt;&lt; in.rdbuf(); str = out.str(); } typedef parse_info&lt;string::iterator&gt; Info; JSIGrammar g; Info pi = parse(str.begin(), str.end(), g, space_p); if ( pi.hit ) { cout &lt;&lt; "Match" &lt;&lt; endl; cout &lt;&lt; "Full: " &lt;&lt; (pi.full ? "Yes" : "No") &lt;&lt; endl; cout &lt;&lt; "Length: " &lt;&lt; pi.length &lt;&lt; endl; } else { cout &lt;&lt; "No match" &lt;&lt; endl; } return 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/331 Trac 1.4.3 biochimia Tue, 14 Dec 2004 05:19:04 GMT status changed https://svn.boost.org/trac10/ticket/331#comment:1 https://svn.boost.org/trac10/ticket/331#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> <pre class="wiki">Logged In: YES user_id=840777 rules must be "alive" while parsing. So, pp_token and pp_number may not be temporary variables within JSIGrammar::definition's constructor. Change them so they become members of JSIGrammar::definition as 'r' is. For rationale, consider what happens when you change the order of the rules' definitions or when you have self-referential rules as happens with the calculator examples in the docs. You may also want to direct spirit questions to spirit's mailing list where you may get more responses. br, João Abecasis </pre> Ticket