<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/110339>110339</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Is the regex [b-a] legal?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Alcaro
</td>
</tr>
</table>
<pre>
```c++
#include <regex>
int main()
{
try {
std::regex r("[\\d-e]");
puts("it's legal");
} catch (std::exception& e) {
puts(e.what());
}
try {
std::regex r("[b-a]");
puts("it's legal");
} catch (std::exception& e) {
puts(e.what());
}
}
```
https://godbolt.org/z/oMvEr5YTs
Output: `The expression contained an invalid character range, such as [b-a] in most encodings.` and `it's legal`
Expected behavior: I'd expect that if I can produce an error saying that [b-a] is invalid, then an input of [b-a] returns that same error.
(Also, if you change it to `[1-0]`, it's illegal in all encodings. The C and C++ specs demand that the 0-9 are ascending and consecutive.)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVMGOqzgQ_Jrm0kpEmgDhwCGTDNIcVnt5lz0auwNeOTayTd5kv35lyMxk3t729CIrILurXFVuI0LQg2VuoXyB8pyJOY7Ot0cjhXdZ79S9hSpfhwR6SSM_Q34EKrSVZlaMUJw8D_wOxetjbfnXNuJVaAt0AGoeK_UDjogY_R2_TaRfiAqKIxTHhRL9gqZF3QnKk9owlOc0Qw0UH9hpjmEt1BGoDmh4EObXKkSE-oxSRDki0OFzK36XPEXtLFCFDNQ8yXpQ8_bnKOLDyn9J_6-pfiN-LzufXr5ePo7_-WzHGKeQdqMOqBuc6p2JW-cHoO4foM79cXv15V8_wjPozzlOc4TiiFDlP0ZGfp88h6CdRelsFNqyQmFR25swWqEchRcyskcv7MBAJwyzHFEE_MwOtcWrCxHZSqe0HcIWqhyFVWmXb_l9t_D6PrGMrLDnUdy080nYG1Ctki6WEeMoIuoLvqEUFifv1Cw56WPvnccg7toOa9WTnPAhP8mNI9vV0TRHdJenQs9x9jas-CCuvNJunzUCHY4muMSkL3h3c4rEDow6YnTJIJQvu02eeqjKl7LVsDaL5RSOMOYpG0y5n5Z4Tut1xjCxDKj4miYXNXFkzDcNCs8ogmSbsAtGOhtYzlHfeAvUZKotVFM0IuN2V1O9rw9NWWdje2hE0feiafJLtRdlQQdVlnu69DIviXac6ZZy2ucN1VTsyrLeylpeSqp2VXUQilUO-5yvQputMbdr6qxMhzBzu9vlRdFkRvRswvLVIrL8E5fV5VKdM98m0KafhwD73OgQwxdN1NFw-xYWl-t9_DqUtVGKLpu9aX9pch3Hud9KdwXqEtvjsZm8-5tlBOoWDQGoe4i8tfRvAAAA__9Nqo0p">