Boost C++ Libraries: Ticket #3021: proto::extends compilation error with function type on gcc-3.4.5 https://svn.boost.org/trac10/ticket/3021 <p> The following test case has been simplified from Spirit's actions.cpp test case. This does not compile with gcc-3.4.5 or 3.4.6: </p> <pre class="wiki">#include &lt;boost/proto/proto.hpp&gt; using namespace boost::proto; void func() {} struct my_tag {}; struct my_terminal : extends&lt; terminal&lt;my_tag&gt;::type, my_terminal &gt; {}; my_terminal const foo = my_terminal(); int main() { foo[&amp;func]; // OK foo[func]; // fails with gcc-3.4.5 and 3.4.6 return 0; } </pre><p> with this error: </p> <pre class="wiki">boost/proto/extends.hpp: In member function '...': test.cpp:15: instantiated from here boost/proto/extends.hpp:505: error: call of overloaded `as_child(void (&amp;)())' is ambiguous boost/proto/traits.hpp:2050: note: candidates are: typename result_of::as_child&lt;T, Domain, void&gt;::type as_child(T&amp;, typename disable_if&lt;is_const&lt;T&gt;, detail::undefined&gt;::type*) [with Domain = default_domain, T = void ()()] boost/proto/traits.hpp:2059: note: typename result_of::as_child&lt;const T, Domain, void&gt;::type as_child(const T&amp;) [with Domain = default_domain, T = void ()()] </pre><p> (but it works fine with gcc-4.1.2 and later). </p> <p> <br /> </p> <p> I think it is because these versions of gcc do not implement DR-214 resolution (<a class="ext-link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#214"><span class="icon">​</span>Partial ordering of function templates</a>, see <a class="ext-link" href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19203"><span class="icon">​</span>gcc bug #19203</a>), so: </p> <ul><li>since the disable_if on as_child does not disable the non-const overload (since the function type is not const), </li><li>gcc reports the 2 overloads as ambiguous instead of choosing the const one. </li></ul><p> A solution would probably be to also disable the non-const as_child overload if the argument type is a function? </p> <p> Thanks,<br /> François </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3021 Trac 1.4.3 Eric Niebler Thu, 21 May 2009 17:03:31 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3021#comment:1 https://svn.boost.org/trac10/ticket/3021#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">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/53158" title="workaround for gcc-3.4 bug, fixes #3021">[53158]</a>) workaround for gcc-3.4 bug, fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3021" title="#3021: Bugs: proto::extends compilation error with function type on gcc-3.4.5 (closed: fixed)">#3021</a> </p> Ticket