[PATCH][libcxx] regex does not handle (?=^) correctly

Howard Hinnant hhinnant at apple.com
Fri Jun 28 12:15:42 PDT 2013


Committed revision 185196.

Thanks William!  Could you create a patch for CREDITS.TXT?

Thanks,
Howard

On May 24, 2013, at 1:13 AM, William Fisher <william.w.fisher at gmail.com> wrote:

> This patch addresses http://llvm.org/bugs/show_bug.cgi?id=11118
> 
> A bug in __lookahead::exec causes /(?=^)b/ to match "ab". When `__lookahead::__exec` makes a recursive call to `__exp_.__match_at_start_ecma`, it passes true for the value of `__at_first`. This causes a beginning-of-line anchor (^) inside a lookahead assertion to match anywhere in the text.
> 
> Here is a test case (before the patch, both asserts fail).
> 
> ```
> #include <regex>
> #include <cassert>
> 
> int main() 
> {
>     assert(!std::regex_search("ab", std::regex("(?=^)b")));
>     assert(!std::regex_search("ab", std::regex("a(?=^)b")));
> }
> ```
> 
> 
> 
> <patch.txt>_______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list