program_options: wild write
I'm making progess on using program_options. Using std::exception& gave me the real error message; but problems still remain. po::options_description desc("Options"); desc.add_options() ("help,h", " Display this help message.") ("version", " Display the version... .") ("limit", po::value<unsigned int>()->default_value(1), " This is the concurrency limit ...") ); // specify the single, required graph file positional parameter po::positional_options_description pd; pd.add("graph_file", 1); po::variables_map vm; po::store(po::command_line_parser(argc, argv). options(desc). positional(pd).run(), vm); po::notify(vm); //... code that references vm... I still can't get the positional parameter, but I've got other problem to research first. The options_descriptions above defines --limit as an unsigned integer with a default value of 1. It does get a default value of 1, and it will let you specify another unsigned integer value. But if you specify a non-unisgned integer (e.g., --limit=xxx or --limit=-5), then it bypasses the exception handling and calls Dr. Watson. The reported error is a wild write to unwritable memory. Any ideas how to chase this problem? Merrill
Hi Merrill, before you commit suicide, what's the exception message? Can you try this: unsigned int nLimit = 1; desc.add_options() ("help,h", " Display this help message.") ("version", " Display the version... .") ("limit", po::value<unsigned int>( &nLimit )->default_value(1), " This is the concurrency limit ...") ); Note the use of a local variable "nLimit" that gets the limit value from the command line. Greets, Christian
Merrill Cornish wrote:
I still can't get the positional parameter, but I've got other problem to research first.
The options_descriptions above defines --limit as an unsigned integer with a default value of 1. It does get a default value of 1, and it will let you specify another unsigned integer value. But if you specify a non-unisgned integer (e.g., --limit=xxx or --limit=-5), then it bypasses the exception handling and calls Dr. Watson. The reported error is a wild write to unwritable memory.
Any ideas how to chase this problem?
Yes: 1. Provide a *minimal complete example* reproducing the problem. Obviously, I can't run your example under valgrind if you did not provide the example. 2. Provide the exact message from "Dr. Watson". I suppose it reports something more than "wild write to unwritable memory". - Volodya
participants (4)
-
Christian Henning
-
Merrill Cornish
-
Pedro Lamarão
-
Vladimir Prus