blob: a4d5db6c14a48e1ea01dafce63b67da3e49a9f8e [file] [log] [blame]
// { 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();
}