Patrick Palka 158ad5f969 libstdc++/regex: Make DFS executor non-recursive [PR86164]
This patch replaces the recursive implementation of the DFS executor
with an iterative one using an explicit heap-based stack.  System
stack usage of the executor is now constant with respect to input size
rather than linear, avoding stack overflow errors when processing
long inputs.

	PR libstdc++/86164

libstdc++-v3/ChangeLog:

	* include/bits/regex.h (__detail::_Executor): Use inline
	namespace _V2.
	* include/bits/regex_executor.h (__detail::_ExecutorFrame):
	Declare.
	(__detail::_Executor): Use inline namespace _V2.
	(__detail::_Executor::_M_node): Declare.
	(__detail::_Executor::_M_frames): New data member.
	* include/bits/regex_executor.tcc (__detail::_ExecutorFrameOpcode):
	New.
	(__detail::_ExecutorFrameBase): New.
	(__detail::_ExecutorFrame): New.
	(__detail::_Executor): Use inline namespace _V2.
	(__detail::_Executor::_M_rep_once_more): Replace recursive
	_M_dfs calls with an _S_opcode_next frame push, and any work
	after such calls with an appropriate frame push.
	(__detail::_M_handle_repeat): Likewise.
	(__detail::_M_handle_subexpr_begin): Likewise.
	(__detail::_M_handle_subexpr_end): Likewise.
	(__detail::_M_handle_line_begin_assertion): Likewise.
	(__detail::_M_handle_line_end_assertion): Likewise.
	(__detail::_M_handle_word_boundary): Likewise.
	(__detail::_M_handle_subexpr_lookahead): Likewise.
	(__detail::_M_handle_match): Likewise.
	(__detail::_M_handle_backref): Likewise.
	(__detail::_M_handle_accept): Likewise.
	(__detail::_M_handle_alternative): Likewise.
	(__detail::_M_node): Factored out from _M_dfs.
	(__detail::_M_dfs): Push an initial frame to _M_frames that
	visits the starting node and pass this stack each subroutine.
	Pop the latest _ExecutorFrame from _M_frames and handle
	appropriately according to its _ExecutorFrameOpcode.  Loop until
	_M_frames is empty.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2026-01-30 12:23:40 -05:00
2026-01-02 09:56:11 +01:00
2026-01-21 00:16:32 +00:00
2026-01-10 00:16:49 +00:00
2026-01-10 00:16:49 +00:00
2026-01-10 00:16:49 +00:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-02 10:47:06 +01:00
2026-01-16 00:16:30 +00:00
2026-01-10 00:16:49 +00:00
2026-01-30 00:16:31 +00:00
2026-01-25 00:16:27 +00:00
2026-01-18 00:16:31 +00:00
2026-01-14 00:16:30 +00:00
2025-12-30 00:16:33 +00:00
2026-01-21 00:16:32 +00:00
2026-01-02 09:56:11 +01:00
2026-01-13 00:16:32 +00:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-02 00:16:23 +00:00
2025-12-30 00:16:33 +00:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-27 00:16:29 +00:00
2025-12-30 00:16:33 +00:00
2026-01-23 00:16:27 +00:00
2026-01-19 09:56:51 +01:00
2026-01-19 09:56:51 +01:00
2025-11-30 01:52:24 +01: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 4.2 GiB
Languages
C++ 30.7%
C 30.2%
Ada 14.4%
D 6.1%
Go 5.7%
Other 12.4%