Boost C++ Libraries: Ticket #2655: pure virtual function called under gcc -O2 https://svn.boost.org/trac10/ticket/2655 <p> The following code results in a pure virtual function call under gcc-4.3.0 20080428 (red hat 4.3.0-8) with -O2 but not with -O1. The innermost non-error-handling stack frame gdb shows is </p> <p> boost::xpressive::detail::end_matcher::match&lt;<span class="underline">gnu_cxx::</span>normal_iterator&lt;char const*, std::string&gt;, boost::xpressive::detail::no_next&gt; </p> <p> at boost/xpressive/detail/core/flow_control.hpp:64. </p> <p> --- #include &lt;string&gt; #include &lt;boost/xpressive/xpressive_static.hpp&gt; #include &lt;boost/xpressive/regex_algorithms.hpp&gt; using std::string; namespace xpr = boost::xpressive; </p> <p> int main() { </p> <blockquote> <p> string text = "at"; xpr::sregex <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> = xpr::as_xpr('a'), </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a> = 'b' &gt;&gt; <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a>, <a class="changeset" href="https://svn.boost.org/trac10/changeset/3" title="Tweak disclaimer text">r3</a> = <a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a> | <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a>; </p> </blockquote> <p> xpr::regex_replace(text, <a class="changeset" href="https://svn.boost.org/trac10/changeset/3" title="Tweak disclaimer text">r3</a>, string("")); return 0; </p> </blockquote> <p> } --- </p> <p> The problem goes away if I do any one of these: </p> <ul><li>switch the order of the alternation </li><li>replace '<a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a>' in the definition of <a class="changeset" href="https://svn.boost.org/trac10/changeset/3" title="Tweak disclaimer text">r3</a> with xpr::as_xpr('a') </li><li>replace '<a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a>' in the definition of <a class="changeset" href="https://svn.boost.org/trac10/changeset/3" title="Tweak disclaimer text">r3</a> with ('b' &gt;&gt; <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a>) </li><li>match to a string not starting with 'a' </li></ul><p> It does not go away if I do one of these: </p> <ul><li>change the 'b' in <a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a> to 'a' </li><li>stick a by_ref() around <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> in the definition of <a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a> </li></ul><p> Any ideas? </p> <p> Thank you. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2655 Trac 1.4.3 Eric Niebler Wed, 14 Jan 2009 17:23:50 GMT status changed https://svn.boost.org/trac10/ticket/2655#comment:1 https://svn.boost.org/trac10/ticket/2655#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> I can confirm this error with gcc-4.3 and gcc-4.2 but not gcc-4.1 or msvc-9.0. It seems likely to be a gcc optimization bug, but I don't have time to investigate right now. I'll get to it as time allows. </p> Ticket Eric Niebler Fri, 20 Mar 2009 03:06:34 GMT <link>https://svn.boost.org/trac10/ticket/2655#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2655#comment:2</guid> <description> <p> I've filed a gcc bug. Still looking for a work-around and can use the help of a very good gcc debugging guru. </p> <p> <a class="ext-link" href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39509"><span class="icon">​</span>http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39509</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Fri, 20 Mar 2009 03:51:46 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2655#comment:3 https://svn.boost.org/trac10/ticket/2655#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/51863" title="work around gcc optimizer bug fixes #2655">[51863]</a>) work around gcc optimizer bug fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2655" title="#2655: Support Requests: pure virtual function called under gcc -O2 (closed: fixed)">#2655</a> </p> Ticket