Re: [PATCH v2] libstdc++: Fix std::vector::append_range for overlapping ranges

2025-03-24 Thread Jonathan Wakely
On Mon, 24 Mar 2025 at 14:18, Patrick Palka wrote: > > On Mon, 24 Mar 2025, Jonathan Wakely wrote: > > > Unlike insert_range and assign_range, the append_range function does not > > have a precondition that the range doesn't overlap *this. That means we > > need to avoid relocating the existing el

Re: [PATCH v2] libstdc++: Fix std::vector::append_range for overlapping ranges

2025-03-24 Thread Jonathan Wakely
On Mon, 24 Mar 2025 at 12:40, Tomasz Kaminski wrote: > As a note reserving for empty vector: > + // If there are no existing elements it's safe to allocate now. > + if (__sz == 0) > + reserve(__n); > Will invalidate v.begin(), v.end(), so if the incoming range

[PATCH v2] libstdc++: Fix std::vector::append_range for overlapping ranges

2025-03-24 Thread Jonathan Wakely
Unlike insert_range and assign_range, the append_range function does not have a precondition that the range doesn't overlap *this. That means we need to avoid relocating the existing elements until after copying from the range. This means I need to revert r15-8488-g3e1d760bf49d0e which made the fro

Re: [PATCH v2] libstdc++: Fix std::vector::append_range for overlapping ranges

2025-03-24 Thread Patrick Palka
On Mon, 24 Mar 2025, Jonathan Wakely wrote: > Unlike insert_range and assign_range, the append_range function does not > have a precondition that the range doesn't overlap *this. That means we > need to avoid relocating the existing elements until after copying from > the range. This means I need

Re: [PATCH v2] libstdc++: Fix std::vector::append_range for overlapping ranges

2025-03-24 Thread Tomasz Kaminski
On Mon, Mar 24, 2025 at 1:08 PM Jonathan Wakely wrote: > Unlike insert_range and assign_range, the append_range function does not > have a precondition that the range doesn't overlap *this. That means we > need to avoid relocating the existing elements until after copying from > the range. This m