C++ PATCH for C++20 P0388R4 (conversions to arrays of unknown bounds) and CWG 1307 (c++/91364, c++/69531)

Jason Merrill jason@redhat.com
Mon Oct 7 14:37:00 GMT 2019


On 10/6/19 11:39 AM, Tam S. B. wrote:
> Hi, sorry for chiming in.
> 
> IIUC P0388R4 does not allow implicit conversion from `T(*)[]` to `T(*)[N]`. Per [conv.qual]/3,
> 
>> A prvalue of type `T1` can be converted to type `T2` if the cv-combined type of `T1` and `T2` is `T2`.
> 
> When T1 is `T(*)[]` and T2 is `T(*)[N]`, the "cv-combined type" is `T(*)[]`, which is not the same as T2 = `T(*)[N]`, so conversion should not be permitted.
> 
> That is to say, either `comp_ptr_ttypes_real` should not use `comp_array_types`, or `comp_array_types` should be extended to handle this case correctly.
> 
> Also, does this patch permit conversion from `T(*)[N]` to `const T(*)[]`? I think [conv.qual] allows this conversion, but IIUC `comp_array_types` will return false in this case, as it uses `same_type_p`.

Agreed.

Jason



More information about the Gcc-patches mailing list