Modify

#11922 closed Bugs (fixed)

Rev f4a61d breaks introduces ambiguity.

Reported by: layus Owned by: John Maddock
Milestone: To Be Determined Component: multiprecision
Version: Boost 1.60.0 Severity: Regression
Keywords: Cc: jzmaddock

Description

The following code used to work before 1.60.

#include <memory>
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mp_int;

class Int {
  public:
    Int(const mp_int& i) {};
    Int(const Int& i) = delete;
};

int main() {
    mp_int i(10);
    std::shared_ptr<Int> p = std::make_shared<Int>(i + 10);
    return 0;
}

But the changes introduced by the following commit, merged into boost-1.60.0, breaks it. The compiler cannot pick the constructor because there is some ambiguity. (i.e. "call of overloaded ‘Int(...)’ is ambiguous")

commit f4a61d5f47c4b03e2c0d3f2bed55fe8f7bb07620
Author: jzmaddock <XXX>
Date:   Thu Mar 12 17:55:13 2015 +0000

    Add explicit conversion operators and tests to expression templates.

I must admit I am not even sure why there is ambiguity, but since the only way to call Int(const Int&) is to call Int(const mp_int&) first to get an Int there should be no ambiguity for the compiler here.

Attachments (0)

Change History (1)

comment:1 Changed 22 months ago by John Maddock

Resolution: fixed
Status: newclosed

The ambiguity exists because there are 2 conversion paths:

expression template -> number -> Int expression template -> Int -> Int copy constructor

However the error message is particularly unhelpful :(

I believe I have this fixed in https://github.com/boostorg/multiprecision/commit/df773c7ab293118eb29eac52067a0466431c9a96

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain John Maddock.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.