Re: [Boost-bugs] [Boost C++ Libraries] #3813: program_options::options_description.add() permits duplicate options

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3813: program_options::options_description.add() permits duplicate options
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-12-16 09:23:24

#3813: program_options::options_description.add() permits duplicate options
  Reporter: Matthew Wesley <weslem-boosttrac@…> | Owner: s_ochsenknecht
      Type: Bugs | Status: new
 Milestone: Boost 1.42.0 | Component: program_options
   Version: Boost 1.41.0 | Severity: Problem
Resolution: | Keywords:

Comment (by Ralph van Etten <ralph@…>):

 This bug still exists in 1.48.0, the documentation says it will throw
 duplicate_variable_error but this exception is never thrown anywere.

 I needed this functionality but I was wondering if it can be added to the
 library without breaking other code using program_options.

 For instance, program_options/test/exception_test.cpp depends on
 add_options() not to throw an exception (even though the documentation
 says it will throw and exception as it adds the same option twice) to test
 the ambiguous_option exception.

 It seems to me duplicate_variable_error and ambiguous_option are the same
 kind of error but thrown at different times. The first is (should be)
 thrown when the same option is added twice. The latter is thrown only
 after parsing/storing the command line '''and''' the option is actually
 used on the command line.

 Is this behavior intentional?

 I prefer the add_options() function to throw an exception (or even assert)
 when a duplicate option is added because IMHO it is an error which should
 be solved by the programmer before the program can actually run.

 However, fixing this might break a lot of code so at least the
 documentation should be updated and the duplicate_variable_error should be

 I can create a patch for either solution, but I am not sure which one is

Ticket URL: <>
Boost C++ Libraries <>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:08 UTC