static bool mycompare(const string &a, const string &b)
{
return a.size() <= b.size();
}
int main()
{
vector<string> words;
sort(words.begin(),words.end(),mycompare);
}
I am getting "Error : Address sanitizer : heap buffer overflow on address.". But if change comparator function operator from "<=" to "<" then it compiles fine. I am not able to understand this error if <= operator is used. Input is ["ksqvsyq","ks","kss","czvh","zczpzvdhx","zczpzvh","zczpzvhx","zcpzvh","zczvh","gr","grukmj","ksqvsq","gruj","kssq","ksqsq","grukkmj","grukj","zczpzfvdhx","gru"]