Patrick Palka 8661f4faa8 libstdc++: Fix ranges::search_n for random access iterators [PR97828]
My ranges transcription of the std::search_n implementation for random
access iterators missed a crucial part of the algorithm which the
existing tests didn't exercise.  When __remainder is less than __count
at the start of an iteration of the outer while loop, it means we're
continuing a partial match of __count - __remainder elements from the
previous iteration.  If at the end of the iteration we don't complete
this partial match, we need to reset __remainder so that it's only
offset by the size of the most recent partial match before starting the
next iteration.

This patch fixes this appropriately, mirroring how it's done in the
corresponding std::search_n implementation.

libstdc++-v3/ChangeLog:

	PR libstdc++/97828
	* include/bits/ranges_algo.h (__search_n_fn::operator()): Check
	random_access_iterator before using the backtracking
	implementation.  When the backwards scan fails prematurely,
	reset __remainder appropriately.
	* testsuite/25_algorithms/search_n/97828.cc: New test.
2020-11-17 10:28:20 -05:00
2020-09-10 10:17:51 +02:00
2020-11-17 00:16:27 +00:00
2020-10-04 00:16:21 +00:00
2020-10-30 00:16:29 +00:00
2020-09-25 00:16:27 +00:00
2020-10-12 00:16:25 +00:00
2020-10-21 00:16:36 +00:00
2020-11-12 00:16:39 +00:00
2020-09-25 00:16:27 +00:00
2020-11-17 00:16:27 +00:00
2020-11-02 20:53:00 +00:00
2020-11-10 07:25:32 -08:00
2020-11-15 00:16:26 +00:00
2020-11-14 00:16:38 +00:00
2020-10-02 00:16:27 +00:00
2020-10-12 00:16:25 +00:00
2020-11-14 00:16:38 +00:00
2020-11-14 00:16:38 +00:00
2020-09-11 00:16:28 +00:00
2020-11-16 12:52:43 +01:00
2020-11-17 00:16:27 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 3.1 GiB
Languages
C 48%
Ada 18.3%
C++ 14.1%
Go 7%
GCC Machine Description 4.6%
Other 7.7%