Opened 8 years ago

Closed 8 years ago

#10882 closed Bugs (fixed)

error C2668: 'boost::swap' : ambiguous call to overloaded function (MSVC)

Reported by: Gabor Marton <martongabesz@…> Owned by: Antony Polukhin
Milestone: Boost 1.58.0 Component: variant
Version: Boost 1.56.0 Severity: Problem
Keywords: compile error Cc:

Description

The attached source file does not compile with a specific version of MSVC compiler. It complains about 'boost::swap' ambiguous call to overloaded function, which could be void boost::swap or void boost::detail::variant::move_swap_fallback::swap. Compiler output and compiler version output attached.

Attachments (5)

boost_variant_bug.cpp (372 bytes ) - added by Gabor Marton <martongabesz@…> 8 years ago.
compiler_output (23.5 KB ) - added by Gabor Marton <martongabesz@…> 8 years ago.
compiler_version (172 bytes ) - added by Gabor Marton <martongabesz@…> 8 years ago.
boost-1.57.0-fix-boost-variant-ambiguous-call-to-swap-boost-trac-10882.patch (8.3 KB ) - added by Thomas Riccardi <riccardi@…> 8 years ago.
fix backported on boost 1.57.0
boost-1.55.0-fix-boost-variant-ambiguous-call-to-swap-boost-trac-10882.patch (8.7 KB ) - added by Thomas Riccardi <riccardi@…> 8 years ago.
fix backported on boost 1.55.0

Download all attachments as: .zip

Change History (12)

by Gabor Marton <martongabesz@…>, 8 years ago

Attachment: boost_variant_bug.cpp added

by Gabor Marton <martongabesz@…>, 8 years ago

Attachment: compiler_output added

by Gabor Marton <martongabesz@…>, 8 years ago

Attachment: compiler_version added

comment:1 by Gabor Marton <martongabesz@…>, 8 years ago

comment:2 by Antony Polukhin, 8 years ago

Milestone: To Be DeterminedBoost 1.58.0
Owner: changed from ebf to Antony Polukhin
Status: newassigned

comment:3 by Antony Polukhin, 8 years ago

Fixed in develop branch. tests added in this commit. Will be merged to the master branch soon.

comment:4 by Thomas Riccardi <riccardi@…>, 8 years ago

Since which Boost version this issue is present? At least 1.56, but what about earlier versions (like 1.55)?

And does this ambiguous call resolution cause a risk on other compilers (like gcc)? Does it work by luck on gcc? Is this luck stable? Or is there a risk that under some more complicated scenario the issue could happen on gcc too (without the fix)?

in reply to:  4 ; comment:5 by Antony Polukhin, 8 years ago

Replying to Thomas Riccardi <riccardi@…>:

Since which Boost version this issue is present? At least 1.56, but what about earlier versions (like 1.55)?

Looks like this issue exists from the very beginning of the Varinat library.

And does this ambiguous call resolution cause a risk on other compilers (like gcc)?

Yes

Does it work by luck on gcc? Is this luck stable? Or is there a risk that under some more complicated scenario the issue could happen on gcc too (without the fix)?

Issue happen if a class located in boost:: namespace is being swapped and boost/swap.hpp is included. Anyway, it's a compile-time error, so you'll definitely know if you are hit by this issue.

by Thomas Riccardi <riccardi@…>, 8 years ago

fix backported on boost 1.57.0

by Thomas Riccardi <riccardi@…>, 8 years ago

fix backported on boost 1.55.0

in reply to:  5 comment:6 by Thomas Riccardi <riccardi@…>, 8 years ago

Replying to apolukhin:

Replying to Thomas Riccardi <riccardi@…>:

Since which Boost version this issue is present? At least 1.56, but what about earlier versions (like 1.55)?

Looks like this issue exists from the very beginning of the Varinat library.

And does this ambiguous call resolution cause a risk on other compilers (like gcc)?

Yes

Does it work by luck on gcc? Is this luck stable? Or is there a risk that under some more complicated scenario the issue could happen on gcc too (without the fix)?

Issue happen if a class located in boost:: namespace is being swapped and boost/swap.hpp is included. Anyway, it's a compile-time error, so you'll definitely know if you are hit by this issue.

Thank you for all your precise answers.

I added to this ticket 2 patches that backport the fix for this issue on boost 1.55.0 and 1.57.0.

comment:7 by Antony Polukhin, 8 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.