add(const char * word); can modify the word passed.
To reproduce:
Hunspell * hunspell = new Hunspell("grammarFile-non-utf8", "emptyDictionary");
std::string test = "MamA";
g_debug("before: %s", test.c_str());
hunspell->add(test.c_str());
g_debug("after: %s", test.c_str());
result:
before: MamA
after: Mama
If you pass a constant string, ( hunspell->add("MamA"); ) you might get a segmentation fault.
That's because:
int HashMgr::add(const char * word) is called, and it calls:
add_hidden_capitalized_word((char *) word, wbl, wcl, flags, al, NULL, captype); //casting away constness of word
In HashMgr::add_hidden_capitalized_word(), if utf8 is false, it will do:
mkallsmall(word, csconv);
mkinitcap(word, csconv);
which will modify word.