Boost C++ Libraries: Ticket #13393: [scope_exit] (Boost >= 1.65) VS 2015 internal compiler error in lambda https://svn.boost.org/trac10/ticket/13393 <p> Hi, </p> <p> starting from Boost version 1.65 and using VS 2015 Update 3 (MSVC 19.00) the following code </p> <p> int main() { </p> <blockquote> <p> auto check_property = []() { </p> <blockquote> <p> int test = 0; BOOST_SCOPE_EXIT(test) { </p> <blockquote> <p> test = 42; </p> </blockquote> <p> }BOOST_SCOPE_EXIT_END </p> </blockquote> <p> }; </p> </blockquote> <blockquote> <p> return 0; </p> </blockquote> <p> } </p> <p> raises an internal compiler error: fatal error C1001: An internal error has occurred in the compiler. (compiler file 'msc1.cpp', line 1468). With earlier Boost versions it compiles fine. </p> <p> I figured out that the problem is in &lt;boost/typeof/typeof.hpp&gt;. Since commit 12e1fe615a34c9a5e6ebe3ddf629c6491a50aa9d (DanielaE committed on Apr 14, 2017) in line 214 ff VS 2015 (w/o explicit #defines) includes &lt;boost/typeof/decltype.hpp&gt;. Before the commit VS 2015 included &lt;boost/typeof/native.hpp&gt;. </p> <p> It seems that VS 2015 has problems in lambda when &lt;boost/typeof/decltype.hpp&gt; is included. </p> <p> Unfortunately, the only way getting back the old behavior was defining BOOST_NO_CXX11_DECLTYPE or BOOST_NO_CXX11_TEMPLATE_ALIASES, but this would have major side-effects. </p> <p> I would propose a new macro called BOOST_TYPEOF_MSVC_NATIVE such that when defined &lt;boost/typeof/native.hpp&gt; is included. </p> <p> A working solution is replacing lin 18 in &lt;boost/typeof/typeof.hpp&gt; by </p> <p> #if !defined(BOOST_TYPEOF_MSVC_NATIVE) &amp;&amp; !defined(BOOST_NO_CXX11_DECLTYPE) &amp;&amp; !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) &amp;&amp; !defined(BOOST_TYPEOF_EMULATION) </p> <p> Tobias </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13393 Trac 1.4.3 Tobias Loew Sun, 14 Jan 2018 10:19:18 GMT <link>https://svn.boost.org/trac10/ticket/13393#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13393#comment:1</guid> <description> <p> The problem was a change in Boost.Typeof. A pull request to fix it was accepted (<a class="ext-link" href="https://github.com/boostorg/typeof/pull/11"><span class="icon">​</span>https://github.com/boostorg/typeof/pull/11</a>). I've also added a new test to Boost.Scope_Exit, but it isn't merged yet (<a class="ext-link" href="https://github.com/boostorg/scope_exit/pull/5"><span class="icon">​</span>https://github.com/boostorg/scope_exit/pull/5</a>). </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Tobias Loew</dc:creator> <pubDate>Sun, 14 Jan 2018 10:19:48 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/13393#comment:2 https://svn.boost.org/trac10/ticket/13393#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket