Boost C++ Libraries: Ticket #5141: class template 'value' (bind.hpp) can corrupt compilability of sound code https://svn.boost.org/trac10/ticket/5141 <p> I encountered the following situation. For a new project I combined some code like: </p> <pre class="wiki">#include &lt;boost/my_lib/my_robust_portable_code.hpp&gt; </pre><p> with some other code </p> <pre class="wiki">#include &lt;boost/malicious/side_effect_code.hpp&gt; #include &lt;boost/my_lib/my_robust_portable_code.hpp&gt; </pre><p> with the effect, that <code>my_robust_portable_code.hpp</code> did not compile anymore. Although I found a fix, applicable to <code>my_robust_portable_code.hpp</code>, I think that such a <code>&lt;boost/malicious/side_effect_code.hpp&gt;</code> should generally not be acceptable for independent components of boost. </p> <p> In the concrete case <code>&lt;boost/tread.hpp&gt;</code> has this malicious potential to confuse msvc-[8..10] when it preceded some of my <code>boost/icl</code> files. <code>&lt;boost/tread.hpp&gt;</code> has the potential to break the code of any other boost library and any user code. As the example below shows the corrupted code is not extremely nuts and might occur else were. </p> <p> Fortunately I was able to locate the problem: </p> <p> It's at boost/bind/bind.hpp(112): </p> <pre class="wiki">namespace _bi{ ... template&lt;class T&gt; class value { ... }; ... } //namespace _bi </pre><p> This is a minimal program to demonstrate how <code>class value</code> can confuse msvc: </p> <pre class="wiki">#include &lt;boost/config.hpp&gt; //--- from boost/bind/bind.hpp(112) namespace _bi{ template&lt;class T&gt; class value{}; } //--- affected code --------------------------------------- template &lt;class Type&gt; struct some_attribute { BOOST_STATIC_CONSTANT(int, value = 0); }; template &lt;class Type&gt; struct some_predicate { BOOST_STATIC_CONSTANT(bool, value = ( some_attribute&lt;Type&gt;::value &lt; 0) //error C2059: syntax error : ')' //IF class template value defined before ); }; </pre><p> Although I frankly don't know, how exactly msvc is derailed, it seems to have problems with <code>value</code> in </p> <pre class="wiki">some_attribute&lt;Type&gt;::value &lt; 0 </pre><p> a construction that is extremely frequent due to meta programming conventions introduced by Dave's and Aleksey's <code>boost::mpl</code>. So for a fix I tried to rename <code>class value</code> by something else like <code>class _value</code>. Fortunately this is possible, because the class template is a local implementation object used in <code>boost/bind/bind.hpp</code> only. </p> <p> After renaming, I successfully ran all tests from boost/bind. Find the patch file attached. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5141 Trac 1.4.3 Joachim Faulhaber Sat, 29 Jan 2011 22:51:18 GMT attachment set https://svn.boost.org/trac10/ticket/5141 https://svn.boost.org/trac10/ticket/5141 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_bind_bind_hpp.patch</span> </li> </ul> <p> Patch of bost/bind/bind.hpp replacing template class value by _value </p> Ticket Peter Dimov Wed, 11 Dec 2013 18:23:27 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5141#comment:1 https://svn.boost.org/trac10/ticket/5141#comment:1 <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">wontfix</span> </li> </ul> <p> Closing as wontfix as too old. Please reopen if still relevant. </p> Ticket