Opened 6 years ago
Last modified 4 years ago
#12820 new Bugs
Unsigned value type accepts negative argument"'`--
Reported by: | Owned by: | Vladimir Prus | |
---|---|---|---|
Milestone: | To Be Determined | Component: | program_options |
Version: | Boost 1.58.0 | Severity: | Problem |
Keywords: | 1 | Cc: | arachni@… |
Description
In program_options, an option with e.g. value<std::uint32_t>()
will accept negative arguments. A positional will not work without preceding --
because the minus sign is treated as the option character, though. So it's:
mycommand --foo-level -1
or
mycommand --foo-level=-1
or
mycommand -- -1
Assuming foo-level takes a std::uint32_t
(and is the first positional option for the latter example), this will be accepted and converted to 4294967295 (aka UINT32_MAX
). Likewise,
mycommand --foo-level -4294967196
will result in a value of 100. There's a workaround with a custom validator discussed at:
But this should not be necessary IMO.
Change History (1)
follow-up: 1 comment:1 by , 4 years ago
Cc: | added |
---|---|
Keywords: | 1 added |
Summary: | Unsigned value type accepts negative argument → Unsigned value type accepts negative argument"'`-- |
1