Opened 10 years ago

Last modified 10 years ago

#7067 new Bugs

The same options in the different groups cause exception while parsing configuration file.

Reported by: Grzegorz Andrejczuk <g.andrejczuk@…> Owned by: Vladimir Prus
Milestone: To Be Determined Component: program_options
Version: Boost 1.49.0 Severity: Problem
Keywords: Cc:

Description

Preconditions: There are two option descriptions defined, containing the same options. The options are stored in the configuration file and grouped by the group.

Result: options_descriptions add method adds two groups parse method throws unknown option exception with cat1.op1

namespace po::boost::program_options; void test() { po::options_description cat1("cat1"); cat1.add_options()

("op1", po::value<std::string>(), "op1") ("op2", po::value<std::string>(), "op2") ("op3", po::value<std::string>(), "op3") ("op4", po::value<std::string>(), "op4");

po::options_description cat2("cat2"); cat2.add_options()

("op1", po::value<std::string>(), "op1") ("op2", po::value<std::string>(), "op2") ("op3", po::value<std::string>(), "op3") ("op4", po::value<std::string>(), "op4");

po::options_description full("full"); full.add(cat1).add(cat2);

po::variables_map map;

boost::filesystem::path path("option.ini");

try {

po::store(po::parse_config_file<char>("option.ini", full), map); exception is thrown "Unknown option cat1.op1" po::notify(map);

} catch(std::exception & ex) {

std::cout << ex.what() << std::endl;

}

option.ini:

[cat1]

op1=v1 op2=v2 op3=v3 op4=v4

[cat2]

op1=v5 op2=v6 op3=v7 op4=v8

Change History (1)

comment:1 by g.andrejczuk@…, 10 years ago

it also happens in boost 1.50.0

Note: See TracTickets for help on using tickets.