lundi 24 juillet 2017

std::string::erase and std::remove_if segfault

I have this code:

void removeControlChar(std::string* str)
{
    std::string::iterator begin = str->begin();
    std::string::iterator end = str->end();
    str->erase(std::remove_if(begin, end, invalidChar));
}

bool invalidChar(char c)
{
    return !(c >= 33 && c < 128);
}

When I compile it with MSVC 2017 it works but it segfault with Clang and GCC. What's wrong with it ?

Aucun commentaire:

Enregistrer un commentaire