cxxopts icon indicating copy to clipboard operation
cxxopts copied to clipboard

out of range argument not detected

Open senhalil opened this issue 3 years ago • 2 comments

An unsigned long long parameter throws a cxxopts::argument_incorrect_type when called with ULLONG_MAX + 1 as expected

terminate called after throwing an instance of 'cxxopts::argument_incorrect_type'
  what():  Argument ‘18446744073709551616’ failed to parse

but cxxopts parses happily a much larger value 28446744073709551616 (ULLONG_MAX + 1e19) incorrectly and sets the value of the parameter to 1e19 - 1.

I feel like both of those values should be refused. Am I doing something wrong or is this a bug related to the internal working of cxxopts?

senhalil avatar Jun 12 '21 17:06 senhalil

The first looks right, but the second sounds like a bug.

jarro2783 avatar Jun 15 '21 07:06 jarro2783

Not immediately related to this bug; however, while I have you here, I couldn't find a way to set limits to the parameters via cxxopts. Is there a way to limit a numerical parameter to an arbitrary range or set of valid values without creating a custom class?

senhalil avatar Jun 15 '21 08:06 senhalil