]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Fix allocator propagation in regex algorithms [PR107376]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 25 Oct 2022 12:03:12 +0000 (13:03 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 18 Mar 2024 13:50:54 +0000 (13:50 +0000)
commit5c156f5be49007a5434452335f29844eb17868a6
treea5151855c2f2aa23a65a935771b9b5b75ae53b16
parente35b26c2442b61e7f45deb5ef3062d0ab6ec584b
libstdc++: Fix allocator propagation in regex algorithms [PR107376]

The PR points out that we assume the match_results allocator is default
constuctible, which might not be true. We also have a related issue with
unwanted propagation from an object that might have an unequal
allocator.

Ideally we use the same allocator type for _State_info::_M_match_queue
but that would be an ABI change now. We should investigate if that can
be done without breaking anything, which might be possible because the
_Executor object is short-lived and never leaks out of the regex_match,
regex_search, and regex_replace algorithms. If we change the mangled
name for _Executor then there would be no ODR violations when mixing old
and new definitions. This commit does not attempt that.

libstdc++-v3/ChangeLog:

PR libstdc++/107376
* include/bits/regex_executor.h (_Executor::_Executor): Use same
allocator for _M_cur_results and _M_results.
* include/bits/regex_executor.tcc (_Executor::_M_main_dispatch):
Prevent possibly incorrect allocator propagating to
_M_cur_results.
* testsuite/28_regex/algorithms/regex_match/107376.cc: New test.

(cherry picked from commit 988dd22ec6665117e8587389ac85389f1c321c45)
libstdc++-v3/include/bits/regex_executor.h
libstdc++-v3/include/bits/regex_executor.tcc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/107376.cc [new file with mode: 0644]
This page took 0.06317 seconds and 6 git commands to generate.