Boost C++ Libraries: Ticket #854: multi_index, multi_array collision https://svn.boost.org/trac10/ticket/854 <pre class="wiki">I'm not the most experienced user, so pl. excuse me if I'm just missing something. venkyn@gmail.com -------test.cc-------- /* simply including this causes the following errors on compilation */ #include &lt;boost/multi_index_container.hpp&gt; #include &lt;boost/multi_array.hpp&gt; int main() { /* this is one of the examples in the Boost multiarray documentation */ typedef boost::multi_array&lt;double, 3&gt; array_type; array_type A( boost::extents[3][4][2] ); A[0][0][0] = 3.14; } ---------- Trying to compile this: $&gt; /home/sapo/software/compilers/gcc/gcc-3.2.3-install/bin/g++ -I/home/sapo/software/compilers/gcc/gcc-3.2.3-install/include -I/home/sapo/software/boost//include/boost-1_33_1 -L/home/sapo/software/compilers/gcc/gcc-3.2.3-install/lib -lm -o test src/test.cc /home/sapo/software/boost/include/boost-1_33_1/boost/multi_array/multi_array_ref.hpp: In member function `boost::const_multi_array_ref&lt;T, NumDims, T*&gt;::reference boost::multi_array_ref&lt;T, NumDims&gt;::operator[](boost::const_multi_array_ref&lt;T, NumDims, T*&gt;::index) [with T = double, unsigned int NumDims = 3]': src/test.cc:12: instantiated from here /home/sapo/software/boost/include/boost-1_33_1/boost/multi_array/multi_array_ref.hpp:515: no matching function for call to `boost::const_multi_array_ref&lt;double, 3, double*&gt;::access(boost::type&lt;boost::detail::multi_array::sub_array&lt;double, 2&gt; &gt;, index&amp;, double*, const size_type*, const index*, const index*)' /home/sapo/software/boost/include/boost-1_33_1/boost/multi_array/subarray.hpp: In member function `boost::detail::multi_array::const_sub_array&lt;T, NumDims, T*&gt;::reference boost::detail::multi_array::sub_array&lt;T, NumDims&gt;::operator[](boost::detail::multi_array::const_sub_array&lt;T, NumDims, T*&gt;::index) [with T = double, unsigned int NumDims = 2]': src/test.cc:12: instantiated from here /home/sapo/software/boost/include/boost-1_33_1/boost/multi_array/subarray.hpp:261: no matching function for call to ` boost::detail::multi_array::const_sub_array&lt;double, 2, double*&gt;::access( boost::type&lt;boost::detail::multi_array::sub_array&lt;double, 1&gt; &gt;, index&amp;, double*&amp;, const size_type*, const index*, const index*)' /home/sapo/software/boost/include/boost-1_33_1/boost/multi_array/subarray.hpp: In member function `boost::detail::multi_array::const_sub_array&lt;T, NumDims, T*&gt;::reference boost::detail::multi_array::sub_array&lt;T, NumDims&gt;::operator[](boost::detail::multi_array::const_sub_array&lt;T, NumDims, T*&gt;::index) [with T = double, unsigned int NumDims = 1]': src/test.cc:12: instantiated from here /home/sapo/software/boost/include/boost-1_33_1/boost/multi_array/subarray.hpp:261: no matching function for call to ` boost::detail::multi_array::const_sub_array&lt;double, 1, double*&gt;::access( boost::type&lt;double&amp;&gt;, index&amp;, double*&amp;, const size_type*, const index*, const index*)' </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/854 Trac 1.4.3 nobody Wed, 14 Mar 2007 21:04:18 GMT <link>https://svn.boost.org/trac10/ticket/854#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/854#comment:1</guid> <description> <pre class="wiki">Logged In: NO I should clarify that it is the A[0][0][0] = 3.14 line that gives the compilation errors. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>joaquintides</dc:creator> <pubDate>Wed, 14 Mar 2007 22:38:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/854#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/854#comment:2</guid> <description> <pre class="wiki">Logged In: YES user_id=911241 Originator: NO Hello, I've just tried your snippet in GCC 3.4.4 and it works OK, so the problem seems to be confined to quite old versions of the compiler. Can you upgrade? If you can't you might try the following: replace the five occurrences of super_type::replace(...) at lines 215, 515 and 578 of boost/multi_array/multi_array_ref.hpp and lines 76 and 261 of of boost/multi_array/subarray.hpp with: this-&gt;replace(...) Does the error vanish? If so, you might want to propose these changes as a patch to the Boost.MultiArray author. Hope this helps, please report back, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>joaquintides</dc:creator> <pubDate>Thu, 15 Mar 2007 10:13:24 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/854#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/854#comment:3</guid> <description> <pre class="wiki">Logged In: YES user_id=911241 Originator: NO Hello again, I've gotten access to a GCC 3.2 installation and been investigating the issue a little more. The problem can also be triggered by the following snippet: #include &lt;boost/serialization/access.hpp&gt; #include &lt;boost/multi_array.hpp&gt; int main() { typedef boost::multi_array&lt;double, 3&gt; array_type; array_type A( boost::extents[3][4][2] ); A[0][0][0] = 3.14; } or even with this: namespace some_namespace{ class access{}; } #include &lt;boost/multi_array.hpp&gt; int main() { typedef boost::multi_array&lt;double, 3&gt; array_type; array_type A( boost::extents[3][4][2] ); A[0][0][0] = 3.14; } This is a nasty GCC bug: basically, it chokes on 'access' being defined as a class somewhere and as a member function in some other place. I've checked and the hack I proposed in my previous post does *not* work. But fortunately you've got two options to solve the problem that I've just confirmed to be operational: 1. If you're not using the serialization capabilities of Boost.MultiIndex, try globally defining the macro BOOST_MULTI_INDEX_DISABLE_SERIALIZATION. This has the collateral effect that &lt;boost/serialization/access.hpp&gt; won't be internally included by B.MI headers, thus avoding the 'access' name clash. 2. Do the following replacements in boost/multi_array/multi_array_ref.hpp: Line 215: &lt; return super_type::access(boost::type&lt;const_reference&gt;(), &gt; return this-&gt;template access&lt;const_reference&gt;(boost::type&lt;const_reference&gt;(), Line 515: &lt; return super_type::access(boost::type&lt;reference&gt;(), &gt; return this-&gt;template access&lt;reference&gt;(boost::type&lt;reference&gt;(), Line 578: &lt; return super_type::access(boost::type&lt;const_reference&gt;(), &gt; return this-&gt;template access&lt;const_reference&gt;(boost::type&lt;const_reference&gt;(), and the following in boost/multi_array/subarray.hpp: Line 76: &lt; return super_type::access(boost::type&lt;const_reference&gt;(), &gt; return this-&gt;template access&lt;const_reference&gt;(boost::type&lt;const_reference&gt;(), Line 261: &lt; return super_type::access(boost::type&lt;reference&gt;(), &gt; return this-&gt;template access&lt;reference&gt;(boost::type&lt;reference&gt;(), Either method will do. As for the convenience of applying the changes in #2 to the CVS version of Boost.MultiArray, my opinion is that this is not suitable for the official version of the lib because a) the offending compiler is quite old; b) the error conditions are so general that to be perfectly safe one would have to protect the code against many other possible name clashes apart from 'access' --basically, the compiler seems to be too broken. For instance, the following snippet hits the same problem with a different symbol 'access_element': namespace some_namespace{ class access_element{}; } #include &lt;boost/multi_array.hpp&gt; int main() { typedef boost::multi_array&lt;double, 3&gt; array_type; array_type A( boost::extents[3][4][2] ); boost::array&lt;array_type::index,3&gt; idx = {{0,0,0}}; A(idx) = 3.14; } Hope this helps. Please report back, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>nobody</dc:creator> <pubDate>Thu, 15 Mar 2007 10:17:56 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/854#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/854#comment:4</guid> <description> <pre class="wiki">Logged In: NO Thanks for the qiuck response, joaquintides! Unfortunately, I don't think your suggestion fixed it for me: &gt; /home/sapo/software/compilers/gcc/gcc-3.2.3-install/bin/g++ -I/home/sapo/software/compilers/gcc/gcc-3.2.3-install/include -I/home/sapo/software/boost//include/boost-1_33_1 -L/home/sapo/software/compilers/gcc/gcc-3.2.3-install/lib -lm -o test src/test.cc /home/sapo/software/boost/include/boost-1_33_1/boost/multi_array/multi_array_ref.hpp: In member function `boost::const_multi_array_ref&lt;T, NumDims, T*&gt;::reference boost::multi_array_ref&lt;T, NumDims&gt;::operator[](boost::const_multi_array_ref&lt;T, NumDims, T*&gt;::index) [with T = double, unsigned int NumDims = 3]': src/test.cc:12: instantiated from here /home/sapo/software/boost/include/boost-1_33_1/boost/multi_array/multi_array_ref.hpp:515: no matching function for call to `boost::multi_array_ref&lt;double, 3&gt;::access( boost::type&lt;boost::detail::multi_array::sub_array&lt;double, 2&gt; &gt;, index&amp;, double*, const size_type*, const index*, const index*)' /home/sapo/software/boost/include/boost-1_33_1/boost/multi_array/subarray.hpp: In member function `boost::detail::multi_array::const_sub_array&lt;T, NumDims, T*&gt;::reference boost::detail::multi_array::sub_array&lt;T, NumDims&gt;::operator[](boost::detail::multi_array::const_sub_array&lt;T, NumDims, T*&gt;::index) [with T = double, unsigned int NumDims = 2]': src/test.cc:12: instantiated from here /home/sapo/software/boost/include/boost-1_33_1/boost/multi_array/subarray.hpp:261: no matching function for call to `boost::detail::multi_array::sub_array&lt;double, 2&gt;::access(boost::type&lt;boost::detail::multi_array::sub_array&lt;double, 1&gt; &gt;, index&amp;, double*&amp;, const size_type*, const index*, const index*)' /home/sapo/software/boost/include/boost-1_33_1/boost/multi_array/subarray.hpp: In member function `boost::detail::multi_array::const_sub_array&lt;T, NumDims, T*&gt;::reference boost::detail::multi_array::sub_array&lt;T, NumDims&gt;::operator[](boost::detail::multi_array::const_sub_array&lt;T, NumDims, T*&gt;::index) [with T = double, unsigned int NumDims = 1]': src/test.cc:12: instantiated from here /home/sapo/software/boost/include/boost-1_33_1/boost/multi_array/subarray.hpp:261: no matching function for call to `boost::detail::multi_array::sub_array&lt;double, 1&gt;::access(boost::type&lt;double&amp;&gt;, index&amp;, double*&amp;, const size_type*, const index*, const index*)' I can work around it for now. I guess I should pass this report on to Boost.MultiArray. Thanks again. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>nobody</dc:creator> <pubDate>Thu, 15 Mar 2007 10:22:37 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/854#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/854#comment:5</guid> <description> <pre class="wiki">Logged In: NO Ah, I didn't see your second comment when I replied. I'll try your suggestions -- and eventually upgrade the compiler on this machine. Thanks. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>joaquintides</dc:creator> <pubDate>Fri, 16 Mar 2007 07:11:26 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/854#comment:6 https://svn.boost.org/trac10/ticket/854#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> Ticket