Description
libc++ supports backreferences as a non-standard extension to POSIX extended regular expressions (see Section 9.5.1 of the POSIX standard, which specifies that the token "BACKREF" is applicable to basic regular expressions only).
The bad_backref.cpp
test assumes this non-standard extension as well: It expects in various places that the error_backref
error code is thrown on illegal backreferences for extended and egrep regular expressions. Example:
These extended and egrep mode tests fail for MSVC STL, because it does not support backreferences in extended regular expressions in accordance with the POSIX standard. Consequently, it produces the error code error_escape
instead of error_backref
, because there is no concept of backreferences in extended regular expressions from MSVC STL's point of view.
Side note: The test also tries to check in various places that some regular expressions with backreferences are parsed successfully:
But what is actually checked here is that no regex_error
with code error_backref
is thrown. Because of this, MSVC STL actually passes a few lines that try to check that backreferences are parsed successfully in extended and egrep mode even though it doesn't support backreferences in these modes at all:
(If these four lines are changed to actually test a successful parse, they should be moved to a libc++-specific test file since they test a non-standard extension.)