http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52522

             Bug #: 52522
           Summary: Overloaded functions called with initializer lists
                    considered ambiguous
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: dgstef...@numerica.us


Consider:

#include <vector>
using std::vector;
class Matrix{};
class Vector{};

Matrix horizontalConcat(const std::vector<Vector>& vectors);
Matrix horizontalConcat(const std::vector<Matrix>& matrices);

int main()
{
 Matrix a,b;
 horizontalConcat({a,b});
}

GCC 4.4 and 4.5 in C++0X mode (E.G., g++ testA.cpp -c -ansi -std=c++0x ) accept
this code and do the right thing.  However, 4.6.3 produces:

/usr/local/compilers/4.6/bin/g++ testA.cpp -c -ansi -std=c++0x 

estA.cpp: In function ‘int main()’:
testA.cpp:25:24: error: call of overloaded ‘horizontalConcat(<brace-enclosed
initializer list>)’ is ambiguous
testA.cpp:25:24: note: candidates are:
testA.cpp:12:8: note: Matrix horizontalConcat(const std::vector<Vector>&)
testA.cpp:13:8: note: Matrix horizontalConcat(const std::vector<Matrix>&)

However, sending an initializer list containing 3 or more Matrices works fine. 
Also, removing the vector<Vector> overloaded function removes the warning.

In principle there could be some ambiguity, when using an initializer list of
two elements, between calling vector's initializer list ctor or calling one of
its other ctors, but here I don't see that either, since vector<Matrix> doesn't
have a ctor that takes two matrices.

At any rate, either GCC 4.6 is incorrectly concluding that the function call is
ambiguous, or it's producing a very confusing error message.

Thanks very much.

Reply via email to