blob: a4d5db6c14a48e1ea01dafce63b67da3e49a9f8e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// { dg-do run { target c++11 } }
// { dg-timeout-factor 2 }
#include <regex>
#include <string>
#include <testsuite_hooks.h>
void test01()
{
const std::string s(1ul, '\0');
std::regex re(s);
VERIFY( std::regex_match(s, re) ); // PR libstdc++/84110
#if __cpp_exceptions
using namespace std::regex_constants;
// See https://gcc.gnu.org/pipermail/gcc-patches/2021-October/582486.html
using std::regex_constants::extended;
for (auto syn : {basic, extended, awk, grep, egrep})
{
try
{
std::regex{s, syn}; // '\0' is not valid for other grammars
VERIFY( false );
}
catch (const std::regex_error&)
{
}
}
#endif
}
void test02()
{
const std::string s("uh-\0h", 5);
std::regex re(s);
VERIFY( std::regex_match(s, re) );
}
int main()
{
test01();
test02();
}
|