Skip to content

[libc++] <regex>: Undefined backreferences should match empty string #133360

Open
@Alcaro

Description

@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 - most or all of the libc++ failures are this, #133314, or both.

Metadata

Metadata

Assignees

No one assigned

    Labels

    libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.regexIssues related to regex

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions