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

Sebastian Redl sebastian.redl at getdesigned.at
Mon Apr 4 10:57:21 PDT 2011


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



More information about the cfe-dev mailing list