https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120330

            Bug ID: 120330
           Summary: regex: [\B] should be legal
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: blubban at gmail dot com
  Target Milestone: ---

#include <regex>

int main()
{
    std::regex("[\\B]");
}


Expected: Successfully construct the object; \B means nothing in [], and should
be an identity escape like \Z.

Actual:
terminate called after throwing an instance of 'std::regex_error'
  what():  Unexpected character within '[...]' in regular expression

https://godbolt.org/z/z8EWWY8hP


libc++ throws the same error, but for a different reason - it doesn't implement
https://cplusplus.github.io/LWG/issue2584 at all, it throws the same error for
[\Z]. https://github.com/llvm/llvm-project/issues/99976

Reply via email to