Boost C++ Libraries: Ticket #3492: Code using Boost accumulators fails to compile in ubuntu amd64 gcc 4.4.1 https://svn.boost.org/trac10/ticket/3492 <p> Hello, </p> <p> The following code (simplified) </p> <pre class="wiki"> #include &lt;iostream&gt; #include &lt;iomanip&gt; #include &lt;boost/bind.hpp&gt; #include &lt;boost/ref.hpp&gt; #include &lt;boost/foreach.hpp&gt; #include &lt;boost/random/mersenne_twister.hpp&gt; #include &lt;boost/random/normal_distribution.hpp&gt; #include &lt;boost/random/variate_generator.hpp&gt; #include &lt;boost/accumulators/accumulators.hpp&gt; #include &lt;boost/accumulators/statistics/stats.hpp&gt; #include &lt;boost/accumulators/statistics/min.hpp&gt; #include &lt;boost/accumulators/statistics/count.hpp&gt; #include &lt;boost/accumulators/statistics/max.hpp&gt; #include &lt;boost/accumulators/statistics/mean.hpp&gt; #include &lt;boost/accumulators/statistics/variance.hpp&gt; #include &lt;boost/accumulators/statistics/error_of.hpp&gt; #include &lt;boost/accumulators/statistics/error_of_mean.hpp&gt; #include &lt;boost/accumulators/statistics/moment.hpp&gt; #include &lt;boost/accumulators/statistics/density.hpp&gt; using namespace boost::accumulators; int main(int argc, char* argv[]) { std::vector&lt; double &gt; data; std::copy(std::istream_iterator&lt;double&gt;(std::cin), std::istream_iterator&lt;double&gt;(), std::back_inserter(data)); data.erase(std::remove_if (data.begin(), data.end(), negative), data.end()); // changed features-&gt;stats, same result accumulator_set&lt;double, stats&lt;tag::count, tag::density, tag::min, tag::max, tag::mean, tag::error_of&lt;tag::mean&gt;, tag::variance, tag::moment&lt;2&gt; &gt; &gt; acc ( tag::density::cache_size = data.size(), tag::density::num_bins = 16 ); std::for_each(data.begin(), data.end(), boost::bind&lt;void&gt;( boost::ref(acc), _1 ) ); // Display the results ... if (argc == 1) { std::cout &lt;&lt; "Samples: " &lt;&lt; count(acc) &lt;&lt; std::endl; std::cout &lt;&lt; "Mean: " &lt;&lt; mean(acc) &lt;&lt; std::endl; std::cout &lt;&lt; "ErrorOf: " &lt;&lt; error_of&lt; tag::mean &gt;(acc)&lt;&lt; std::endl; std::cout &lt;&lt; "Moment 2: " &lt;&lt; moment&lt;2&gt;(acc) &lt;&lt; std::endl; std::cout &lt;&lt; "Variance: " &lt;&lt; extract_result&lt; tag::variance &gt;( acc )&lt;&lt; std::endl; std::cout &lt;&lt; "Min: " &lt;&lt; extract_result&lt; tag::min &gt;( acc )&lt;&lt; std::endl; std::cout &lt;&lt; "Max: " &lt;&lt; extract_result&lt; tag::max &gt;( acc )&lt;&lt; std::endl; } </pre><p> fails to compile in Ubuntu 9.10 amd64 gcc 4.4.1 </p> <pre class="wiki">Using built-in specs. Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.1-4ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --enable-objc-gc --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu4) </pre><pre class="wiki">/usr/local/include/boost/accumulators/statistics_fwd.hpp: In function ‘int main(int, char**)’: /usr/local/include/boost/accumulators/statistics_fwd.hpp:72: error: ‘template&lt;class Feature&gt; struct boost::accumulators::tag::error_of’ is not a function, /usr/local/include/boost/accumulators/statistics/error_of.hpp:77: error: conflict with ‘template&lt;class T2, class Arg1, class A0, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14&gt; typename boost::accumulators::detail::extractor_result&lt;Arg1, boost::accumulators::tag::error_of&lt;T2&gt; &gt;::type boost::accumulators::extract::error_of(const Arg1&amp;, const A0&amp;, const A1&amp;, const A2&amp;, const A3&amp;, const A4&amp;, const A5&amp;, const A6&amp;, const A7&amp;, const A8&amp;, const A9&amp;, const A10&amp;, const A11&amp;, const A12&amp;, const A13&amp;, const A14&amp;)’ main.cpp:100: error: in call to ‘error_of’ /usr/local/include/boost/accumulators/statistics_fwd.hpp:91: error: ‘template&lt;int N&gt; struct boost::accumulators::tag::moment’ is not a function, /usr/local/include/boost/accumulators/statistics/moment.hpp:104: error: conflict with ‘template&lt;int T2, class Arg1, class A0, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14&gt; typename boost::accumulators::detail::extractor_result&lt;Arg1, boost::accumulators::tag::moment&lt;T2&gt; &gt;::type boost::accumulators::extract::moment(const Arg1&amp;, const A0&amp;, const A1&amp;, const A2&amp;, const A3&amp;, const A4&amp;, const A5&amp;, const A6&amp;, const A7&amp;, const A8&amp;, const A9&amp;, const A10&amp;, const A11&amp;, const A12&amp;, const A13&amp;, const A14&amp;)’ main.cpp:101: error: in call to ‘moment’ </pre><p> The very same code compiles in Debian 5.0 Lenny </p> <pre class="wiki">Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.2-1.1' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-cld --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.3.2 (Debian 4.3.2-1.1) </pre><p> Thanks in advance </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3492 Trac 1.4.3 Eric Niebler Fri, 30 Oct 2009 15:21:50 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3492#comment:1 https://svn.boost.org/trac10/ticket/3492#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">invalid</span> </li> </ul> <p> Recent versions of gcc take a very "interesting" and unfortunate interpretation of C++'s name lookup rules, and you're getting bitten by them. Since the invocations of 'error_of' and 'moment' have (some of) their template parameters explicitly specified, name look-up is finding the *types* 'error_of' and 'moment' in addition to the functions, and the ambiguity is causing an error. This is a problem with gcc's peculiar interpretation of name look-up, not a problem in accumulators. </p> <p> You can work around the problem by adding namespace qualification to the invocations of 'error_of' and 'moment': </p> <pre class="wiki"> namespace acc = boost::accumulators; acc::moment&lt;2&gt;(acc); </pre> Ticket