On Mon, 16 Aug 2021 at 20:26, Jonathan Wakely via Libstdc++ wrote: > > On Fri, 13 Aug 2021 at 18:10, François Dumont via Libstdc++ > wrote: > > > > I just come back to this email and it sounds like the right moment to > > commit it. > > Ah yes, thanks for the reminder! > > I'll push it tomorrow. > > > > > On 27/02/20 2:06 pm, Jonathan Wakely wrote: > > > These should wait for stage 1 but I'm posting them now for comment. > > > > > > With the change to __gnu_debug::__valid_range we now get a debug > > > assertion for: > > > > > > std::string s; > > > std::min_element(std::string::iterator{}, s.end()); > > > > > > where previously it would just crash with undefined behaviour. Actually, that change doesn't work. Some of our container iterators use a value-initialized iterator as the past-the-end value, so the check in the new __valid_range_aux function incorrectly rejects some valid ranges. Maybe I can make it work for bidirectional iterators, which must be attached to a container to be valid. For now I've only pushed the second half of the patch, optimizing the std::min/max/minmax overloads taking an initializer_list (as attached). Tested powerpc64le-linux, pushed to trunk.