[cfe-dev] suppress "no matching constructor for initialization of" errors?

Jack Howarth howarth at bromo.med.uc.edu
Mon Apr 4 10:32:03 PDT 2011


On Mon, Apr 04, 2011 at 06:55:30PM +0200, Sebastian Redl wrote:
> 
> On 04.04.2011, at 15:20, Jack Howarth wrote:
> 
> >  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?
> 
> Do you have a code example that Clang doesn't allow that you think should be allowed?
> 
> Sebastian

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



More information about the cfe-dev mailing list