When using tclap on Linux (Ubuntu on WSL2), I experienced the following exception:
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::erase: __pos (which is 18446744073709551615) > this->size() (which is 3)
By debugging, I traced the problem to this line:
// CmdLineOutput.h, lines 101-102
p = s.rfind(".exe");
if (p == s.length() - 4) {
The problem happens because my executable's name has 3 charactes, so s.length() - 4
underflows into std::string::npos
. The fix is simple:
// CmdLineOutput.h, lines 101-102
p = s.rfind(".exe");
if (p != std::string::npos and p == s.length() - 4) {
Edit: sorry for the badly formatted message, I'm not used to sourceforge. Here's another go:
Exception message:
Offending code:
Fix:
Thank, I can confirm this. A fix should be forthcoming (but by all means, do apply your patch locally for now - or just check if the length is < 4 and return even before the call to rfind)
Fixed in [57a98f] (with a follow up fix for Windows in [f73351])
Related
Commit: [57a98f]
Commit: [f73351]