Issue 133360
Summary [libc++] `<regex>`: Undefined backreferences should match empty string
Labels libc++
Assignees
Reporter Alcaro
    ```
> /(a)?\1/.exec("")
Array [ "", undefined ]
> /(a)?\1/.exec("a")
Array [ "", undefined ]
> /(a)?\1/.exec("aa")
Array [ "aa", "a" ]
```
~Firefox

But in libc++, the equivalent operations return `null`, `null` and `[ "aa", "a" ]`. The spec is unambiguous; https://262.ecma-international.org/5.1/#sec-15.10.2.9 5.3 says unmatched backreferences should match the empty string.

Full example: https://godbolt.org/z/ndrqej718 (libstdc++ has the same bug)

Found in [this battery of tests](https://godbolt.org/z/6PnbKzTrn) - most or all of the libc++ failures are this, #133314, or both.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to