I'm using TCLAP on Debian (libtclap-dev 1.2.2-1+b1) and I use it to parse messages I send between long-running programs. I put arguments in a std::vector<std::string> and use CmdLine::parse to parse it.
I found that if the vector is empty I get a segmentation fault when CmdLine::parse calls args.front();
I think it would be good if the function would instead throw an exception:</std::string>
if (args.empty()) {
throw CmdLineParseException("The args vector must not be empty, the first entry should contain the program's name.");
}
I messed up the title, I wanted "Check arguments vector is not empty before accessing first element" but it seems I can't edit titles
Sounds reasonable. This will never happen when argv/c comes from the command line, but I don't see why we could not add this check.
Fixed in [9a8967d6f32b4a4b805899026ace355a2ef8177b] for 1.2 and [96fd5eae03553ed380ad66bcabc5219e534ef13d] for 1.4.
Related
Commit: [96fd5e]
Commit: [9a8967]