argparse icon indicating copy to clipboard operation
argparse copied to clipboard

[BUG] parse_args with empty vector crashes

Open Tomdein opened this issue 7 months ago • 0 comments

I wanted to use this lib to parse args in cutom 'interactive console', so I used std::cin to read the input and split it into the std::vectorstd::string and run it in a loop.

But if you input empty line (just press enter) -> empty vector -> argparse crashes in parse_args_internal because the iterators are invalid with empty vector.


You maybe want to do some sanity check for the input.


I solved it in my code by just inserting the name of the command in front of the vector: args.insert(args.begin(), "<program_name>");


Is this an edge case? Yes Did I spend way too much time on this because in my case I do not have access to debugger? Yes

Tomdein avatar Jul 04 '25 14:07 Tomdein