program_options: Printing description problem
Hello, When I try to output options_description to cout (response to --help option, to show all available options) I get an assertion in in xstring header file. It's caused by execution format_paragraph function in option_description.cpp line 381. I narrowed down the problem to the length of the description for an option. This is the code: #include <boost/program_options.hpp> namespace po = boost::program_options; int main(int argc, char **argv){ po::options_description desc("t"); desc.add_options()("h", "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZ"); po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); if(vm.count("h")){std::cout<<desc<<"\n"; return 1;} return 0; } If I remove last Z in the description of h parameter the program works, otherwise it crashes. If I replace the message with some words, meaning if spaces are present, it still crashes (that's how I originally discovered the problem). What am I doing wrong, or how can I avoid this situation (other than decreasing the length of the descriptions for all of my parameters). I'm using boost 1.33.1 (how can I find out what was done to program_options in 1.34.1?) and Microsoft Visual Studio 2005 Professional. The project is compiled as Multi-threaded DLL Thanks. -- Regards, Alexander. http://sjcomp.com
sj@sjcomp.com wrote:
Hello,
When I try to output options_description to cout (response to --help option, to show all available options) I get an assertion in in xstring header file. It's caused by execution format_paragraph function in option_description.cpp line 381. I narrowed down the problem to the length of the description for an option. This is the code:
#include <boost/program_options.hpp> namespace po = boost::program_options; int main(int argc, char **argv){ po::options_description desc("t"); desc.add_options()("h", "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZ"); po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); if(vm.count("h")){std::cout<<desc<<"\n"; return 1;} return 0; } If I remove last Z in the description of h parameter the program works, otherwise it crashes. If I replace the message with some words, meaning if spaces are present, it still crashes (that's how I originally discovered the problem). What am I doing wrong, or how can I avoid this situation (other than decreasing the length of the descriptions for all of my parameters).
I'm using boost 1.33.1 (how can I find out what was done to program_options in 1.34.1?) and Microsoft Visual Studio 2005 Professional. The project is compiled as Multi-threaded DLL
I believe this problem is fixed in 1.34.1. - Volodya
participants (2)
-
sj@sjcomp.com
-
Vladimir Prus