<html><head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Compilers corner</title><link rel="stylesheet" href="boostbook.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.75.2"><link rel="home" href="index.html" title="Meta State Machine (MSM) V2.10"><link rel="up" href="ch04.html" title="Chapter 4. Performance / Compilers"><link rel="prev" href="ch04s04.html" title="Limitations"><link rel="next" href="ch05.html" title="Chapter 5. Questions & Answers"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"> Compilers corner </th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch04s04.html">Prev</a> </td><th width="60%" align="center">Chapter 4. Performance / Compilers</th><td width="20%" align="right"> <a accesskey="n" href="ch05.html">Next</a></td></tr></table><hr></div><div class="sect1" title="Compilers corner"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e3817"></a> Compilers corner </h2></div></div></div><p>Compilers are sometimes full of surprises and such strange errors happened in the course of the development that I wanted to list the most fun for readers’ entertainment.</p><p><span class="underline">VC8</span>: </p><pre class="programlisting">template <class StateType> typename ::boost::enable_if< typename ::boost::mpl::and_< typename ::boost::mpl::not_< typename has_exit_pseudo_states<StateType>::type >::type, typename ::boost::mpl::not_< typename is_pseudo_exit<StateType>::type >::type >::type, BaseState*>::type </pre><p>I get the following error:</p><p>error C2770: invalid explicit template argument(s) for '`global namespace'::boost::enable_if<...>::...' </p><p>If I now remove the first “::” in ::boost::mpl , the compiler shuts up. So in this case, it is not possible to follow Boost’s guidelines.</p><p><span class="underline">VC9</span>:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>This one is my all times’ favorite. Do you know why the exit pseudo states are referenced in the transition table with a “submachine::exit_pt” ? Because “exit” will crash the compiler. “Exit” is not possible either because it will crash the compiler on one machine, but not on another (the compiler was installed from the same disk).</p></li><li class="listitem"><p>Sometimes, removing a policy crashes the compiler, so some versions are defining a dummy policy called WorkaroundVC9.</p></li><li class="listitem"><p>Typeof: While g++ and VC9 compile “standard” state machines in comparable times, Typeof (while in both ways natively supported) seems to behave in a quadratic complexity with VC9 and VC10.</p></li><li class="listitem"><p>eUML: in case of a compiler crash, changing the order of state definitions (first states without entry or exit) sometimes solves the problem.</p></li></ul></div><p><span class="underline">g++ 4.x</span>: Boring compiler, almost all is working almost as expected. Being not a language lawyer I am unsure about the following “Typeof problem”. VC9 and g++ disagree on the question if you can derive from the BOOST_TYPEOF generated type without first defining a typedef. I will be thankful for an answer on this. I only found two ways to break the compiler:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Add more eUML constructs until something explodes (especially with g++-4.4) </p></li><li class="listitem"><p>The build_terminate function uses 2 mpl::push_back instead of mpl::insert_range because g++ would not accept insert_range.</p></li></ul></div><p>You can test your compiler’s decltype implementation with the <a class="link" href="examples/CompilerStressTestEuml.cpp" target="_top">following stress test</a> and reactivate the commented-out code until the compiler crashes.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch04s04.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch04.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch05.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"> Limitations </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 5. Questions & Answers</td></tr></table></div></body></html>