Skip to content

[libc++] regex uncaught exception using libc++, but libstdc++ not #129062

@Zhenhang1213

Description

@Zhenhang1213

code:

#include <iostream>
#include <regex>

int main() {
        const char* pattern = "\\$\\_se";
        std::regex regexObj(pattern);
        const char* testString = "$_se";
        if (std::regex_match(testString, regexObj)) {
        std::cout << "匹配成功!" << std::endl;
    } else {
        std::cout << "匹配失败!" << std::endl;
    }
        return 0;
}

error:

libc++abi: terminating due to uncaught exception of type std::__1::regex_error: The expression contained an invalid escaped character, or a trailing escape.
Program terminated with signal: SIGSEGV

demo:
https://godbolt.org/z/szGjjr5bs

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.regexIssues related to regex

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions