Error while building: ambiguous overload for 'operator*'

Issue #372 resolved
Kemal Ficici created an issue

I'd been trying to build GTSAM on the Jetson TX1, when I came across the following error:

/home/nvidia/gtsam/gtsam/geometry/tests/testPoint2.cpp:107:46: error: ambiguous overload for ‘operator*’ (operand types are ‘int’ and ‘gtsam::Point2’) EXPECT(assert_equal<Point2>( Point2(4,6), 2*Point2(2,3)));

Edit: Fixed it by changing line 107 to:

EXPECT(assert_equal<Point2>( Point2(4,6), Point2(2,3)*2 ));

Comments (10)

  1. Frank Dellaert

    Hi, thanks for reporting. The point of the test is exactly to test left-multiplication with a scalar, so the above fix won't do :-) I'm actually puzzled about the error: the test failure might highlight a real problem of either TX1 compiler, Eigen, or our code (probably the latter?).

  2. Mike Sheffler

    Weird. For what it's worth, I don't see this issue while compiling for the TX2. Are you compiling with gcc or clang? I'm using gcc.

    Looking at the definition of operator *

    /// multiply with scalar
    inline Point2 operator*(double s, const Point2& p) {
    return p * s;
    }
    

    it seems like type coercion from int to double is not working correctly. Just to make sure that that definition of operator * is available, could you change 2*Point2(2,3))) to 2.0*Point2(2,3))) and see if there is still an issue?

  3. Sean Bowman

    The bug is due to a new version of Eigen; they changed how they implemented operator* for matrices somehow -- I encountered it with gcc when building with my system Eigen, but not otherwise. I toyed around with fixes for a while but couldn't come up one other than allowing implicit conversion to Point2 from Eigen::Vector2d (and that conversion constructor is marked explicit so it seemed like a design decision that I didn't want to make a pull request to change...)

  4. Frank Dellaert

    I'm using newest system Eigen in the BitBucket pipelines, and I got an ambiguous overload. When I changed it to 2.0 it worked, however.

  5. Frank Dellaert

    @sbowman is this issue fixed for you with latest develop? Works with Eigen 3.3.4 on Ubuntu 18...

  6. Log in to comment