Bug #1558

nemo::IntVector constuctor is ambiguous

Added by Anonymous almost 11 years ago. Updated over 10 years ago.

Status:ResolvedStart date:07/12/2013
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:-
Target version:NemoMath 0.4

Description

Calling the nemo::IntVector constructor

nemo::IntVector(1, 2)

results in a clang error and gcc warning about ambiguity:

warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: [enabled by default]
/usr/share/NemoMath0.4/../../include/NemoMath0.4/nemo/Vector.h:239:11: note: candidate 1: nemo::MathVector<T>::MathVector(const T&, const T&) [with T = int]
/usr/share/NemoMath0.4/../../include/NemoMath0.4/nemo/Vector.h:220:11: note: candidate 2: nemo::MathVector<T>::MathVector(const nemo::VectorDimension&, generatorType) [with generatorType = unsigned int, T = int]

History

#1 Updated by Anonymous over 10 years ago

Where g++ warns, clang produces an error. From a downstream project (cca on macos):

In file included from /Users/jenkins/workspace/cca-trunk-macos/label/MAC_OS_lion_64bit/cca/test/cca/SplitterTest.cpp:7:
/Users/jenkins/workspace/cca-trunk-macos/label/MAC_OS_lion_64bit/cca/src/cca/nodes/Splitter.h:173:49: error: call to constructor of 'nemo::IntVector' (aka 'MathVector<int>') is ambiguous
                new Splitter<DTOTYPE>(nodename, nemo::IntVector(first, second)));
                                                ^               ~~~~~~~~~~~~~
/Users/jenkins/workspace/cca-trunk-macos/label/MAC_OS_lion_64bit/upstream/NemoMath-0.4.0-Darwin/share/NemoMath0.4/../../include/NemoMath0.4/nemo/Vector.h:220:11: note: candidate constructor [with generatorType = unsigned int]
        explicit MathVector(const VectorDimension &dim, generatorType gen)
                 ^
/Users/jenkins/workspace/cca-trunk-macos/label/MAC_OS_lion_64bit/upstream/NemoMath-0.4.0-Darwin/share/NemoMath0.4/../../include/NemoMath0.4/nemo/Vector.h:239:11: note: candidate constructor
        explicit MathVector(const T &x, const T &y)
                 ^
/Users/jenkins/workspace/cca-trunk-macos/label/MAC_OS_lion_64bit/upstream/NemoMath-0.4.0-Darwin/share/NemoMath0.4/../../include/NemoMath0.4/nemo/Vector.h:200:11: note: candidate constructor
        explicit MathVector(const VectorDimension &dim, const T &val)
                 ^
1 error generated.

#2 Updated by S. Wrede over 10 years ago

Any updates to this problem?

This is currently a blocker to use the AMARSi software on MacOS.

#3 Updated by M. Rolf over 10 years ago

I added a new compile test here:
https://code.cor-lab.org/projects/nemomath/repository/revisions/304/entry/trunk/nemomath/test/compile/IntVectorContructorOverload.cpp
This one builds successfully on jenkin's MacOS.

A closer look on the error message above reveals, it's not an int given to the IntVector constructor, but an unsigned int. In that case it makes sense that it's ambiguous: the IntVector constructor requires an int, and is explicit, which forbids auto-casting to allow different constructors with (dim, value) and (value,value).

Try providing explicitly an int.

#4 Updated by Anonymous over 10 years ago

  • Status changed from Feedback to Resolved
  • % Done changed from 0 to 100

This fixes the issue. Thanks very much for digging into this.
Will fix this downstream.

Also available in: Atom PDF