diff --git a/include/boost/program_options/detail/parsers.hpp b/include/boost/program_options/detail/parsers.hpp index b644aaa17..cdda539ca 100644 --- a/include/boost/program_options/detail/parsers.hpp +++ b/include/boost/program_options/detail/parsers.hpp @@ -24,7 +24,7 @@ namespace boost { namespace program_options { basic_command_line_parser:: basic_command_line_parser(int argc, const charT* const argv[]) : detail::cmdline( - to_internal(std::vector >(argv+1, argv+argc))), + to_internal(std::vector >(argc ? argv+1 : argv, argv+argc))), m_desc() {} diff --git a/include/boost/program_options/parsers.hpp b/include/boost/program_options/parsers.hpp index 057646927..7d902690a 100644 --- a/include/boost/program_options/parsers.hpp +++ b/include/boost/program_options/parsers.hpp @@ -120,7 +120,11 @@ namespace boost { namespace program_options { basic_command_line_parser(const std::vector< std::basic_string >& args); /** Creates a command line parser for the specified arguments - list. The parameters should be the same as passed to 'main'. + list. The parameters should be the same as passed to 'main', meaning: + @param argc Must be non-negative i.e. >= 0 + @param argv Argv[argc] must be 0 e.g. nullptr and + if argc is >0 argv[0] up to argv[argc-1] must point to + null terminated strings */ basic_command_line_parser(int argc, const charT* const argv[]);