Re: [PATCH] c++: Implement -Wrange-loop-construct [PR94695]

2020-09-29 Thread Martin Sebor via Gcc-patches
On 9/28/20 11:34 AM, Marek Polacek wrote: On Fri, Sep 25, 2020 at 04:31:16PM -0600, Martin Sebor wrote: On 9/24/20 6:05 PM, Marek Polacek via Gcc-patches wrote: This new warning can be used to prevent expensive copies inside range-based for-loops, for instance: struct S { char arr[128]; };

Re: [PATCH] c++: Implement -Wrange-loop-construct [PR94695]

2020-09-28 Thread Marek Polacek via Gcc-patches
On Fri, Sep 25, 2020 at 04:31:16PM -0600, Martin Sebor wrote: > On 9/24/20 6:05 PM, Marek Polacek via Gcc-patches wrote: > > This new warning can be used to prevent expensive copies inside range-based > > for-loops, for instance: > > > >struct S { char arr[128]; }; > >void fn () { > >

Re: [PATCH] c++: Implement -Wrange-loop-construct [PR94695]

2020-09-25 Thread Martin Sebor via Gcc-patches
On 9/24/20 6:05 PM, Marek Polacek via Gcc-patches wrote: This new warning can be used to prevent expensive copies inside range-based for-loops, for instance: struct S { char arr[128]; }; void fn () { S arr[5]; for (const auto x : arr) { } } where auto deduces to S and then w

Re: [PATCH] c++: Implement -Wrange-loop-construct [PR94695]

2020-09-25 Thread Jason Merrill via Gcc-patches
On 9/24/20 8:05 PM, Marek Polacek wrote: This new warning can be used to prevent expensive copies inside range-based for-loops, for instance: struct S { char arr[128]; }; void fn () { S arr[5]; for (const auto x : arr) { } } where auto deduces to S and then we copy the big S