http://llvm.org/bugs/show_bug.cgi?id=16240

            Bug ID: 16240
           Summary: regex: regex_replace does not handle \b correctly
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Example from cplusplus.org reference:

  std::string s ("there is a subsequence in the string\n");
  std::regex e ("\\b(sub)([^ ]*)");   // matches words beginning by "sub"

  // using string/c-string (3) version:
  std::cout << std::regex_replace (s,e,"sub-$2");

Testing this with valgrind results in the message: "Invalid read of size 1"

This is because of setting match_prev_avail-flag in a case when we are at the
beginning of a string. This leads to a read operation one byte before the
beginning of the string in "__word_boundary<_CharT, _Traits>::__exec(__state&
__s) const"
The flag is set in "regex_iterator<BidirectionalIterator, _CharT,
_Traits>::operator++()" called from "regex_replace(_OutputIterator __out,
_BiderctionalIterator __first, _BiderctionalIterator __last, 
const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
regex_constants::match_flag_type __flags = regex::constants::match_default)"

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to