dimanche 18 février 2018

C++11 cregex_iterator valgrind errors

I compiled the following small program with gcc 6.3.0 ('g++ -std=c++11'):

#include<iostream>
#include<regex>
#include<cstring>
using namespace std;

int main()
{
    const char *cstr = "abc def.ghi";
    regex r(R"(abc|\w+\.ghi)");
    for (cregex_iterator it(cstr, cstr + strlen(cstr), r); it != cregex_iterator{}; it++)
    {
        cout << (*it).str() << endl;
    }
}

The program output is fine. However, valgrind reports errors:

Conditional jump or move depends on uninitialised value(s)

at 0x10DF98: std::__cxx11::regex_iterator >::operator==(std::__cxx11::regex_iterator > const&) const (in a.out)

by 0x10D796: std::__cxx11::regex_iterator >::operator!=(std::__cxx11::regex_iterator > const&) const (in a.out)

by 0x10C75C: main (in a.out)

Does anyone know what's wrong here?

Aucun commentaire:

Enregistrer un commentaire