Boost C++ Libraries: Ticket #13076: Compilation error on MSVC2015+ on base_from_member used in a class with __declspec(dllexport) https://svn.boost.org/trac10/ticket/13076 <p> Consider the following code: </p> <pre class="wiki">//#define BOOST_NO_CXX11_VARIADIC_TEMPLATES #include &lt;boost/utility/base_from_member.hpp&gt; class __declspec(dllexport) Foo : public boost::base_from_member&lt;int&gt; { public: }; </pre><p> It fails to compile with the following error: </p> <pre class="wiki">example.cpp /opt/compiler-explorer/libs/boost_1_64_0\boost/utility/base_from_member.hpp(135): error C2061: syntax error: identifier 'T' /opt/compiler-explorer/libs/boost_1_64_0\boost/utility/base_from_member.hpp(135): note: This diagnostic occurred in the compiler generated function 'boost::base_from_member&lt;int,0&gt;::base_from_member(T &amp;&amp;...) noexcept(&lt;expr&gt;)' /opt/compiler-explorer/libs/boost_1_64_0\boost/utility/base_from_member.hpp(136): error C2056: illegal expression /opt/compiler-explorer/libs/boost_1_64_0\boost/utility/base_from_member.hpp(136): note: This diagnostic occurred in the compiler generated function 'boost::base_from_member&lt;int,0&gt;::base_from_member(T &amp;&amp;...) noexcept(&lt;expr&gt;)' /opt/compiler-explorer/libs/boost_1_64_0\boost/utility/base_from_member.hpp(135): error C2660: 'operator new': function does not take 2 arguments /opt/compiler-explorer/libs/boost_1_64_0\boost/utility/base_from_member.hpp(135): note: while compiling class template member function 'boost::base_from_member&lt;int,0&gt;::base_from_member&lt;,void&gt;(void) noexcept(&lt;expr&gt;)' /opt/compiler-explorer/libs/boost_1_64_0\boost/utility/base_from_member.hpp(135): error C2056: illegal expression Microsoft (R) C/C++ Optimizing Compiler Version 19.10.25017 for x64 Copyright (C) Microsoft Corporation. All rights reserved. Compiler exited with result code 2 </pre><p> See <a class="ext-link" href="https://godbolt.org/g/CqFg8t"><span class="icon">​</span>https://godbolt.org/g/CqFg8t</a> </p> <p> If I add the <code>BOOST_NO_CXX11_VARIADIC_TEMPLATES</code> define, the issue goes away. The issue affects both MSVC 2015 and MSVC 2017. </p> <p> Even if the underlying cause is the compiler error (to be checked), the issue should at least be prevented by proper compiler version detection. </p> <p> This affects other boost libraries relying on base_from_member, like Boost.Iostreams. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13076 Trac 1.4.3 mwu <mwu-tow@…> Sun, 02 Jul 2017 19:51:15 GMT <link>https://svn.boost.org/trac10/ticket/13076#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13076#comment:1</guid> <description> <p> I reported the bug to Microsoft. They fixed it and fix will likely be available in a future update to VS 2017 C++ toolset. </p> <p> For the meantime, they kindly provided a few possible workarounds to this issue: <a class="ext-link" href="https://developercommunity.visualstudio.com/content/problem/69009/compilation-error-on-msvc2015-on-boostbase-from-me.html?childToView=74166#comment-74166"><span class="icon">​</span>https://developercommunity.visualstudio.com/content/problem/69009/compilation-error-on-msvc2015-on-boostbase-from-me.html?childToView=74166#comment-74166</a> </p> </description> <category>Ticket</category> </item> </channel> </rss>