[cfe-dev] suppress "no matching constructor for initialization of" errors?
Jack Howarth
howarth at bromo.med.uc.edu
Mon Apr 4 14:15:26 PDT 2011
On Mon, Apr 04, 2011 at 07:57:21PM +0200, Sebastian Redl wrote:
>
> On 04.04.2011, at 19:32, Jack Howarth wrote:
>
> > 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++.
> >
> > 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) {}
> > ^ ~~~~
> > tnt/tnt_array1d.h:64:11: note: candidate constructor not viable: 2nd argument ('const int *') would lose const qualifier
> > Array1D(int n, T *a);
> > ^
>
> 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
More information about the cfe-dev
mailing list