Boost C++ Libraries: Ticket #2839: move-emulated swap causes overloaded ambiguous fun call https://svn.boost.org/trac10/ticket/2839 <p> The attached test file is a minimal example of something I have a real-world use for (with T instead of int), and it doesn't compile in MS Visual Studio 2005 or 2008. The error message is too long as it's templated code, but the head follows: 1&gt;c:\Users\dh\products\avir\include\boost/variant/detail/move.hpp(155) : error C2668: 'boost::detail::variant::detail::move_swap::swap' : ambiguous call to overloaded function 1&gt; c:\Users\dh\products\avir\include\boost/variant/detail/move.hpp(141): could be 'void boost::detail::variant::detail::move_swap::swap&lt;T&gt;(T &amp;,T &amp;)' 1&gt; with 1&gt; [ 1&gt; T=T2 1&gt; ] 1&gt; C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\utility(16): or 'void std::swap&lt;T&gt;(_Ty &amp;,_Ty &amp;)' [found using argument-dependent lookup] 1&gt; with 1&gt; [ 1&gt; T=T2, 1&gt; _Ty=T2 1&gt; ] 1&gt; while trying to match the argument list '(T2 , T2 )' 1&gt; c:\Users\dh\products\avir\include\boost/variant/variant.hpp(684) : see reference to function template instantiation 'void boost::detail::variant::move_swap&lt;T&gt;(T &amp;,T &amp;)' being compiled 1&gt; with 1&gt; [ 1&gt; T=T2 1&gt; ] </p> <p> The crucial code is in variant/detail/move.hpp, from line 114. As my variant includes a std::vector&lt;T&gt;*, it finds std::swap in the unqualified call on line 155. </p> <p> The code in question is protected by a BOOST_WORKAROUND that disables it for gcc. I tested this case on gcc, and it works fine, but fails in the same way if I remove the workaround. The comment above it claims that it falls back for "non-conforming compilers," but I'm not convinced that the expected behaviour is conformant. Basic.lookup.koenig says explicitly that "If T is a pointer to U or an array of U, its associated namespaces and classes are those associated with U." </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2839 Trac 1.4.3 st@… Mon, 09 Mar 2009 13:38:18 GMT attachment set https://svn.boost.org/trac10/ticket/2839 https://svn.boost.org/trac10/ticket/2839 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">variant-test.cpp</span> </li> </ul> <p> small test program </p> Ticket st@… Mon, 09 Mar 2009 13:40:23 GMT attachment set https://svn.boost.org/trac10/ticket/2839 https://svn.boost.org/trac10/ticket/2839 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">msvc-output.txt</span> </li> </ul> <p> MSVC output </p> Ticket st@… Mon, 09 Mar 2009 13:41:47 GMT <link>https://svn.boost.org/trac10/ticket/2839#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2839#comment:1</guid> <description> <p> Since the error message got wrapped anyway, I've added the whole output as an attachment. </p> </description> <category>Ticket</category> </item> <item> <author>st@…</author> <pubDate>Mon, 01 Jun 2009 13:43:21 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/2839 https://svn.boost.org/trac10/ticket/2839 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">variant-test.diff</span> </li> </ul> <p> patch adding test case to variant's unit tests </p> Ticket Joseph.Gauterin Tue, 02 Jun 2009 10:13:13 GMT <link>https://svn.boost.org/trac10/ticket/2839#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2839#comment:2</guid> <description> <p> We solved a similar problem in Boost.Swap by providing a templated swap with two template arguments [making it less specialized than std::swap]. I've had a quick look at variant/detail/move.hpp and I think it can be fixed in the same way. </p> </description> <category>Ticket</category> </item> <item> <author>Laurent.Rineau@…</author> <pubDate>Tue, 28 May 2013 16:05:52 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2839#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2839#comment:3</guid> <description> <p> The bug is still in Boost 1.53. Could a maintainer of Boost.Variant have a look at the test case and the proposed patch? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Thu, 26 Sep 2013 07:29:26 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2839#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2839#comment:4</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/85927" title="Optimize and fix ambiguity of move_swap in Boost.Variant (refs #2839) ...">[85927]</a>) Optimize and fix ambiguity of move_swap in Boost.Variant (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2839" title="#2839: Bugs: move-emulated swap causes overloaded ambiguous fun call (closed: fixed)">#2839</a>) Fix GCC-4.8+ warning in variant_reference_test.cpp </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Thu, 26 Sep 2013 07:33:47 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/2839#comment:5 https://svn.boost.org/trac10/ticket/2839#comment:5 <ul> <li><strong>owner</strong> changed from <span class="trac-author">ebf</span> to <span class="trac-author">Antony Polukhin</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Antony Polukhin Mon, 30 Sep 2013 07:39:26 GMT <link>https://svn.boost.org/trac10/ticket/2839#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2839#comment:6</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/86049" title="Commit missing test file for Boost.Variant and uncomment line in ...">[86049]</a>) Commit missing test file for Boost.Variant and uncomment line in Jamfile (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2839" title="#2839: Bugs: move-emulated swap causes overloaded ambiguous fun call (closed: fixed)">#2839</a>) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Tue, 12 Nov 2013 10:16:17 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2839#comment:7 https://svn.boost.org/trac10/ticket/2839#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</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/86650" title="Merge from trunk: * dropped support of antique compilers * fixed issue ...">[86650]</a>) Merge from trunk: </p> <ul><li>dropped support of antique compilers </li><li>fixed issue with ambiguity in swap (fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2839" title="#2839: Bugs: move-emulated swap causes overloaded ambiguous fun call (closed: fixed)">#2839</a>) </li><li>added conditional noexcepts to move assignments, default and move constructors (fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7911" title="#7911: Feature Requests: Mark move constructors and move assignments of varint with ... (closed: fixed)">#7911</a>) </li><li>experimental variadic templates support (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/9163" title="#9163: Feature Requests: Use variadic temnplates in Boost.Variant (closed: fixed)">#9163</a>) </li><li>bunch of size optimizations for assignments and move assignments (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7960" title="#7960: Feature Requests: Optimization for move_assign and assign (closed: obsolete)">#7960</a>) </li><li>minor changes and size optimizations </li></ul> Ticket Antony Polukhin Tue, 12 Nov 2013 10:18:40 GMT milestone changed https://svn.boost.org/trac10/ticket/2839#comment:8 https://svn.boost.org/trac10/ticket/2839#comment:8 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.39.0</span> → <span class="trac-field-new">Boost 1.56.0</span> </li> </ul> Ticket