Boost C++ Libraries: Ticket #12820: Unsigned value type accepts negative argument"'`-- https://svn.boost.org/trac10/ticket/12820 <p> In program_options, an option with e.g. <code>value&lt;std::uint32_t&gt;()</code> will accept negative arguments. A positional will not work without preceding <code>--</code> because the minus sign is treated as the option character, though. So it's: </p> <p> <code>mycommand --foo-level -1</code> </p> <p> or </p> <p> <code>mycommand --foo-level=-1</code> </p> <p> or </p> <p> <code>mycommand -- -1</code> </p> <p> Assuming foo-level takes a <code>std::uint32_t</code> (and is the first positional option for the latter example), this will be accepted and converted to 4294967295 (aka <code>UINT32_MAX</code>). Likewise, </p> <p> <code>mycommand --foo-level -4294967196</code> </p> <p> will result in a value of 100. There's a workaround with a custom validator discussed at: </p> <p> <a class="ext-link" href="http://stackoverflow.com/questions/36800596/disallow-negative-argument-for-unsigned-value-with-boostprogram-options"><span class="icon">​</span>http://stackoverflow.com/questions/36800596/disallow-negative-argument-for-unsigned-value-with-boostprogram-options</a> </p> <p> But this should not be necessary IMO. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12820 Trac 1.4.3 arachni_name <arachni@…> Mon, 23 Jul 2018 10:59:35 GMT summary changed; cc, keywords set https://svn.boost.org/trac10/ticket/12820#comment:1 https://svn.boost.org/trac10/ticket/12820#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">arachni@…</span> added </li> <li><strong>keywords</strong> 1 added </li> <li><strong>summary</strong> <span class="trac-field-old">Unsigned value type accepts negative argument</span> → <span class="trac-field-new">Unsigned value type accepts negative argument"'`--</span> </li> </ul> <p> 1 </p> Ticket