[llvm-bugs] [Bug 51686] New: No exception is thrown when an invalid character range (e.g., [b-a]) is included.

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 31 01:05:57 PDT 2021


            Bug ID: 51686
           Summary: No exception is thrown when an invalid character range
                     (e.g., [b-a]) is included.
           Product: libc++
           Version: 12.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Standards Issues
          Assignee: unassignedclangbugs at nondot.org
          Reporter: w.kensuke at fujitsu.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

#include <regex>
#include <cassert>
#include <cstdio>

static bool error_range_thrown(const char *pat)
    bool result = false;
    try {
        std::regex re(pat);
    } catch (const std::regex_error &ex) {
        result = (ex.code() == std::regex_constants::error_range);
    return result;

int main(int, char**)

This program is created using the regular expression sample described in the
C++ language standard, but it did not throw an exception (as expected).
(e.g., Table 132 in

I've confirmed that this problem can be reproduced using clang 13.0.0 "[C++]
clang HEAD 13.0.0 (https://github.com/llvm/llvm-project.git
c4ed142e695f14ba5675ec6d12226ee706329a0f)" on Wandbox (https://wandbox.org/).
This code throws the exception on gcc-10.1.0 (or other gcc version).

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210831/04f95d61/attachment.html>

More information about the llvm-bugs mailing list