This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/65470] regex_search corrupts matches when haystack is destroyed
- From: "aral at gmx dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 19 Mar 2015 19:24:55 +0000
- Subject: [Bug libstdc++/65470] regex_search corrupts matches when haystack is destroyed
- Auto-submitted: auto-generated
- References: <bug-65470-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65470
--- Comment #4 from aral at gmx dot de ---
Addition: after you referred to the properties of match_results, I had a look
at
http://en.cppreference.com/w/cpp/regex/match_results
which has a clearer wording. However, I still think this clear statement
=> "it's undefined behavior to examine std::match_results if the original
character sequence was destroyed or iterators to it were invalidated for other
reasons"
should be added to the description of the functions that populate the
match_results. "The user" (I, in this case) does not always check the
descriptions of every single function parameter if the function description
seems to give all the information needed to use it.
What could be improved (to avoid bugs going undetected) is to raise an
exception if the match_results are accessed after the haystack has been
destroyed.