suppress "no matching constructor for initialization of" errors?

I am puzzled by the "no matching constructor for initialization of" errors in clang++.
My impression was that this additional level of strictness was added for the benefit of
obj-c++. If so, shouldn't it be optional for normal c++ code and is there a clang compiler
flag to suppress this check?
           Jack

Do you have a code example that Clang doesn't allow that you think should be allowed?

Sebastian

I don't know where you got that impression; we have not increased
the strictness of the C++ type system for the benefit of Objective-C++.
These are not optional errors: the compiler really cannot (or it is
forbidden to) compile your program without a constructor. The one
exception is when binding a reference to a temporary, which C++ '03
technically requires a copy constructor for, but which most vendors
choose not to complain about.

It is, of course, always possible that we have a bug in our logic for
whether a constructor matches a set of arguments, but we can't
answer that without knowing what version o the compiler you're
working with and what code you're getting an error about.

John.

Sebastian,
   I am seeing these errors when building the MacPorts pymol package with clang and clang++.

cd modules/cealign/src
clang++ -c ccealignmodule.cpp -o ccealignmodule.o -Itnt -I. `python2.6-config --include`/Numeric -I../../../layer0 -I../../../ov/src
In file included from ccealignmodule.cpp:32:
In file included from ./ccealignmodule.H:36:
In file included from ./tnt/tnt.h:55:
tnt/tnt_sparse_matrix_csr.h:97:3: error: no matching constructor for initialization of 'Array1D<int>'
                rowptr_(M, r), colind_(nz, c), dim1_(M), dim2_(N) {}
                ^ ~~~~
In file included from ccealignmodule.cpp:32:
In file included from ./ccealignmodule.H:36:
In file included from ./tnt/tnt.h:41:
tnt/tnt_array1d.h:63:19: note: candidate constructor not viable: no known conversion from 'const int *' to 'int const' for 2nd argument
              explicit Array1D(int n, const T &a);
                         ^
tnt/tnt_array1d.h:64:11: note: candidate constructor not viable: 2nd argument ('const int *') would lose const qualifier
                 Array1D(int n, T *a);
                 ^
tnt/tnt_array1d.h:61:11: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
                 Array1D();
                 ^
tnt/tnt_array1d.h:62:19: note: candidate constructor not viable: requires 1 argument, but 2 were provided
              explicit Array1D(int n);
                         ^
tnt/tnt_array1d.h:65:14: note: candidate constructor not viable: requires 1 argument, but 2 were provided
    inline Array1D(const Array1D &A);
             ^
In file included from ccealignmodule.cpp:32:
In file included from ./ccealignmodule.H:36:
In file included from ./tnt/tnt.h:55:
tnt/tnt_sparse_matrix_csr.h:97:18: error: no matching constructor for initialization of 'Array1D<int>'
                rowptr_(M, r), colind_(nz, c), dim1_(M), dim2_(N) {}
                               ^ ~~~~~
In file included from ccealignmodule.cpp:32:
In file included from ./ccealignmodule.H:36:
In file included from ./tnt/tnt.h:41:
tnt/tnt_array1d.h:63:19: note: candidate constructor not viable: no known conversion from 'const int *' to 'int const' for 2nd argument
              explicit Array1D(int n, const T &a);
                         ^
tnt/tnt_array1d.h:64:11: note: candidate constructor not viable: 2nd argument ('const int *') would lose const qualifier
                 Array1D(int n, T *a);
                 ^
tnt/tnt_array1d.h:61:11: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
                 Array1D();
                 ^
tnt/tnt_array1d.h:62:19: note: candidate constructor not viable: requires 1 argument, but 2 were provided
              explicit Array1D(int n);
                         ^
tnt/tnt_array1d.h:65:14: note: candidate constructor not viable: requires 1 argument, but 2 were provided
    inline Array1D(const Array1D &A);
             ^
2 errors generated.

I'll see if I can reduce this into a testcase.
      Jack

Is this the constructor you expect to match? Losing const is an error in C++, and I don't think Clang ever allowed this.

Sebastian

Sebastian,
    Well, FSF gcc 4.6.0 has no complaints about this same source file with same compile flags...

g++-fsf-4.6 -c ccealignmodule.cpp -o ccealignmodule.o -Itnt -I. -I/sw/include/python2.6 -I/sw/include/python2.6/Numeric -I../../../layer0 -I../../../ov/src

If I add -Wall, the only warnings I get from FSF gcc 4.6.0 are...

ccealignmodule.cpp: In function ‘PyObject* findBest(pcePoint, pcePoint, pathCache, int, int, int)’:
ccealignmodule.cpp:553:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
ccealignmodule.cpp: In function ‘TNT::Array2D<double> transpose(const TNT::Array2D<double>&)’:
ccealignmodule.cpp:628:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
ccealignmodule.cpp:629:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

I can open a bug report and provide the preprocessed source a quick and dirty test case.
             Jack

Sebastian,
   I opened http://llvm.org/bugs/show_bug.cgi?id=9627 and uploaded the preprocessed source file
for the problem file from pymol. This ccealignmodule.ii is compiled by Apple llvm-gcc-4.2 from
Xcode 4 and by FSF gcc 4.6.0 on x86_64 darwin without warnings or errors.
       Jack

I have recently seen a few cases with my code where GCC was failing to complain about loss of const within templates. I would not be surprised to see it here.