Re: [PATCH] c++: Fix wrong conversion error with non-viable overload [PR94124]

2020-03-12 Thread Jakub Jelinek via Gcc-patches
On Thu, Mar 12, 2020 at 01:58:20AM -0400, Jason Merrill wrote: > > + if (reuse && nelts < CONSTRUCTOR_NELTS (new_init)) > > + { > > + vec *v = NULL; > > + if (nelts) > > vec_alloc does nothing if nelts is 0, so this test seems unnecessary. OK > either way. I wasn't sure, but now I'

Re: [PATCH] c++: Fix wrong conversion error with non-viable overload [PR94124]

2020-03-11 Thread Jason Merrill via Gcc-patches
On 3/11/20 6:28 PM, Jakub Jelinek wrote: On Wed, Mar 11, 2020 at 04:02:51PM -0400, Jason Merrill via Gcc-patches wrote: We should certainly avoid copying if they're the same. The code above for only copying the bits that aren't going to be thrown away seems pretty straightforward, might as well

Re: [PATCH] c++: Fix wrong conversion error with non-viable overload [PR94124]

2020-03-11 Thread Marek Polacek via Gcc-patches
On Wed, Mar 11, 2020 at 11:28:01PM +0100, Jakub Jelinek via Gcc-patches wrote: > On Wed, Mar 11, 2020 at 04:02:51PM -0400, Jason Merrill via Gcc-patches wrote: > > We should certainly avoid copying if they're the same. The code above for > > only copying the bits that aren't going to be thrown awa

Re: [PATCH] c++: Fix wrong conversion error with non-viable overload [PR94124]

2020-03-11 Thread Jakub Jelinek via Gcc-patches
On Wed, Mar 11, 2020 at 04:02:51PM -0400, Jason Merrill via Gcc-patches wrote: > We should certainly avoid copying if they're the same. The code above for > only copying the bits that aren't going to be thrown away seems pretty > straightforward, might as well use it even if the savings aren't lik

Re: [PATCH] c++: Fix wrong conversion error with non-viable overload [PR94124]

2020-03-11 Thread Jason Merrill via Gcc-patches
On 3/11/20 11:44 AM, Marek Polacek wrote: On Wed, Mar 11, 2020 at 07:52:15AM +0100, Jakub Jelinek via Gcc-patches wrote: On Tue, Mar 10, 2020 at 07:38:17PM -0400, Marek Polacek via Gcc-patches wrote: --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6062,6 +6062,13 @@ reshape_init_array_1 (tree elt_t

Re: [PATCH] c++: Fix wrong conversion error with non-viable overload [PR94124]

2020-03-11 Thread Marek Polacek via Gcc-patches
On Wed, Mar 11, 2020 at 07:52:15AM +0100, Jakub Jelinek via Gcc-patches wrote: > On Tue, Mar 10, 2020 at 07:38:17PM -0400, Marek Polacek via Gcc-patches wrote: > > --- a/gcc/cp/decl.c > > +++ b/gcc/cp/decl.c > > @@ -6062,6 +6062,13 @@ reshape_init_array_1 (tree elt_type, tree max_index, > > reshap

Re: [PATCH] c++: Fix wrong conversion error with non-viable overload [PR94124]

2020-03-10 Thread Jakub Jelinek via Gcc-patches
On Tue, Mar 10, 2020 at 07:38:17PM -0400, Marek Polacek via Gcc-patches wrote: > --- a/gcc/cp/decl.c > +++ b/gcc/cp/decl.c > @@ -6062,6 +6062,13 @@ reshape_init_array_1 (tree elt_type, tree max_index, > reshape_iter *d, >else if (last_nonzero < nelts - 1) > nelts = last_nonzero + 1;

Re: [PATCH] c++: Fix wrong conversion error with non-viable overload [PR94124]

2020-03-10 Thread Jason Merrill via Gcc-patches
On 3/10/20 7:38 PM, Marek Polacek wrote: This is a bad interaction between sharing a constructor for an array and stripping its trailing zero-initializers. Here we reuse a ctor and then strip its 0s. This breaks overload resolution in this test: D can be initialized from {} but not from {0}, so

[PATCH] c++: Fix wrong conversion error with non-viable overload [PR94124]

2020-03-10 Thread Marek Polacek via Gcc-patches
This is a bad interaction between sharing a constructor for an array and stripping its trailing zero-initializers. Here we reuse a ctor and then strip its 0s. This breaks overload resolution in this test: D can be initialized from {} but not from {0}, so if we truncate the constructor not to incl