<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 - regex constructor does not throw an exception for invalid backreferences in basic/grep patterns"
   href="https://bugs.llvm.org/show_bug.cgi?id=34297">34297</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>regex constructor does not throw an exception for invalid backreferences in basic/grep patterns
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

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

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>arthur.j.odwyer@gmail.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 <stdio.h>

int main() {
    std::regex rx("(cat)\\1", std::regex::basic);
    puts("Constructed without throwing: oops!");
    try {
        std::regex_match("(cat)", rx);
    } catch (std::exception& e) {
        puts("regex_match threw instead: oops!");
        puts(e.what());
    }
}

The output is:

Constructed without throwing: oops!
regex_match threw instead: oops!
The expression contained an invalid back reference.

I claim that the constructor should detect and throw on this pattern, rather
than throwing at match time. The same issue happens with the "std::regex::grep"
dialect, too.</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>