When you return the matches array, what you are returning is the address of the first element. This is stored on the stack inside my_completion. Once you return from my_completion that memory is reclaimed and will (most likely) eventually be reused for something else, overwriting the values stored in matches - and yes, that may well be why your application doesn't work - if it isn't right now, it probably will be once you have fixed some other problems, or changed it a bit, or something else, because this is not one of those little warnings that you can safely ignore.
You can fix this in a few different ways. The most obvious is to simply use std::vector<char *> [or better yet std::vector<std::string>] instead:
std::vector<std::string> ReadLineImpl::my_completion ()
{
std::vector<std::string> strings;
strings.push_back("add");
return strings;
}
Edit: So, if the library requires a char ** as per the readline interface,then use this:
char** ReadLineImpl::my_completion ()
{
char **matches = static_cast<char **>malloc(1 * sizeof(char *));
matches[1] = "add";
return matches;
}
Problem solved!