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

2019-10-10 Thread Jonathan Wakely
On 09/10/19 16:29 -0400, Marek Polacek wrote: On Wed, Oct 09, 2019 at 11:01:39AM +0100, Jonathan Wakely wrote: On 07/10/19 14:56 -0400, Jason Merrill wrote: > On 10/7/19 1:42 PM, Marek Polacek wrote: > > @@ -7401,8 +7432,20 @@ convert_like_real (conversion *convs, tree expr, tree fn, int

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

2019-10-09 Thread Jason Merrill
On 10/9/19 4:26 PM, Marek Polacek wrote: On Tue, Oct 08, 2019 at 01:50:17PM -0400, Jason Merrill wrote: That sounds like a bug in grok_reference_init; it isn't properly implementing "Otherwise, if the initializer list has a single element of type E and either T is not a reference type or its

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

2019-10-09 Thread Marek Polacek
On Wed, Oct 09, 2019 at 11:01:39AM +0100, Jonathan Wakely wrote: > On 07/10/19 14:56 -0400, Jason Merrill wrote: > > On 10/7/19 1:42 PM, Marek Polacek wrote: > > > @@ -7401,8 +7432,20 @@ convert_like_real (conversion *convs, tree expr, > > > tree fn, int argnum, > > > error_at (loc,

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

2019-10-09 Thread Marek Polacek
On Tue, Oct 08, 2019 at 01:50:17PM -0400, Jason Merrill wrote: > > > That sounds like a bug in grok_reference_init; it isn't properly > > > implementing > > > > > > "Otherwise, if the initializer list has a single element of type E and > > > either T is not a reference type or its > > >

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

2019-10-09 Thread Jonathan Wakely
On 07/10/19 14:56 -0400, Jason Merrill wrote: On 10/7/19 1:42 PM, Marek Polacek wrote: @@ -7401,8 +7432,20 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, error_at (loc, "cannot bind non-const lvalue reference of " "type %qH to an

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

2019-10-08 Thread Jason Merrill
On 10/7/19 7:26 PM, Marek Polacek wrote: On Mon, Oct 07, 2019 at 02:56:10PM -0400, Jason Merrill wrote: @@ -1378,7 +1381,7 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p, if (same_type_p (from, to)) /* OK */; - else if (c_cast_p &&

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

2019-10-07 Thread Marek Polacek
On Mon, Oct 07, 2019 at 02:56:10PM -0400, Jason Merrill wrote: > > @@ -1378,7 +1381,7 @@ standard_conversion (tree to, tree from, tree expr, > > bool c_cast_p, > > if (same_type_p (from, to)) > > /* OK */; > > - else if (c_cast_p && comp_ptr_ttypes_const (to, from)) > > +

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

2019-10-07 Thread Jason Merrill
On 10/7/19 1:42 PM, Marek Polacek wrote: On Sun, Oct 06, 2019 at 03:39:25PM +, Tam S. B. wrote: Hi, sorry for chiming in. Hi, no worries, comments are welcome! IIUC P0388R4 does not allow implicit conversion from `T(*)[]` to `T(*)[N]`. Per [conv.qual]/3, A prvalue of type `T1` can be

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

2019-10-07 Thread Marek Polacek
On Sun, Oct 06, 2019 at 03:39:25PM +, Tam S. B. wrote: > Hi, sorry for chiming in. Hi, no worries, comments are welcome! > 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

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

2019-10-07 Thread Jason Merrill
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

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

2019-10-06 Thread Tam S. B.
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"

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

2019-10-04 Thread Marek Polacek
This patch implements P0388R4, Permit conversions to arrays of unknown bound, . CWG 393 allowed references to arrays of unknown bound and this C++20 feature allows conversions like void f(int(&)[]); int arr[1]; void g() { f(arr); } int()[] = arr; The proposal