<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - No exception is thrown when an invalid character range (e.g., [b-a]) is included."
   href="https://bugs.llvm.org/show_bug.cgi?id=51686">51686</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>No exception is thrown when an invalid character range  (e.g., [b-a]) is included.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>12.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Standards Issues
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>w.kensuke@fujitsu.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>---
#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) {
        puts("regex_error");
        fflush(stdout);
        result = (ex.code() == std::regex_constants::error_range);
    }   
    return result;
}

int main(int, char**)
{
    assert(error_range_thrown("([b-a])"));
}
---

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
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4713.pdf">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4713.pdf</a>)

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


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>