Opened 10 years ago

Closed 10 years ago

#8009 closed Patches (fixed)

Error message does not show correct option name, if it contains a hyphen

Reported by: Markus Roth <markus.roth@…> Owned by: Vladimir Prus
Milestone: To Be Determined Component: program_options
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc:

Description

When using a long option with a hyphen in its name, the error string does not output the option name, but rather the substring from the rightmost hyphen position.

Example: option foo-bar with double.

./myprogram --foo-bar nonumber

Since "nonumber" cannot be cast into double, it throws an exception. The error message is:

"the argument ('nonumber') for option '--bar' is invalid"

Option name is wrongly quoted as "--bar". Expected is "--foo-bar".

Check the attached example for reproduction. See the attached patch fixing the bug. SVN rev 82783.

Attachments (2)

boost-program-options-hyphen-bug.tar.gz (10.0 KB ) - added by Markus Roth <markus.roth@…> 10 years ago.
Simple bug reproducing example.
boost-program-options-hyphen-bug.patch (522 bytes ) - added by Markus Roth <markus.roth@…> 10 years ago.
Patch.

Download all attachments as: .zip

Change History (3)

by Markus Roth <markus.roth@…>, 10 years ago

Simple bug reproducing example.

by Markus Roth <markus.roth@…>, 10 years ago

Patch.

comment:1 by Vladimir Prus, 10 years ago

Resolution: fixed
Status: newclosed

(In [82805]) Fix report of error for options with dashes.

Fixes #8009. Patch from Markus Roth.

Note: See TracTickets for help on using tickets.