Opened 13 years ago

Closed 13 years ago

#3941 closed Bugs (invalid)

match_results relies on string evaluated by regex_search()

Reported by: David Klamet <davek@…> Owned by: John Maddock
Milestone: Boost 1.43.0 Component: regex
Version: Boost 1.40.0 Severity: Optimization
Keywords: Cc:

Description

See example: If "text" is altered or destroyed, "matches" becomes invalid. Is this the desired behavior?


string pattern="
s*:(
S+)
s*"; string text=" :command ";

boost::regex re(pattern);

boost::match_results<string::const_iterator> matches; bool stat=boost::regex_search(text, matches, re); text=""; Truncate string cout<<matches[1].str()<<endl; <<Throws sting iterator not dereferencable exception

Change History (1)

comment:1 by John Maddock, 13 years ago

Resolution: invalid
Status: newclosed

This is by design: match_results store iterators, not strings.

Note: See TracTickets for help on using tickets.