This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/63631] std::regex_match yielding inexplicable garbage; invalid reads in valgrind


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63631

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |INVALID

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
sregex_iterator::operator->() yields a smatch_results and smatch_results::str()
yields a temporary string.

The reason is that smatch_results doesn't contain strings, it contains
iterators into some other string. When you want to retrieve a match it
constructs a new string from the relevant iterators. That avoids having to
construct all the strings up front when they may never be needed.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]