format: allow undersize integers for conversion
This commit is contained in:
parent
a40e09ed97
commit
fad8181842
@ -729,8 +729,8 @@ namespace util { namespace format { namespace detail {
|
||||
if (spec.k != (std::is_unsigned<ValueT>::value ? specifier::kind::UNSIGNED : specifier::kind::SIGNED))
|
||||
throw conversion_error ("invalid conversion specifier for integer value");
|
||||
|
||||
if (spec.length != sizeof (ValueT))
|
||||
throw length_error ("incorrect value size");
|
||||
if (sizeof (ValueT) > spec.length)
|
||||
throw length_error ("overlength value parameter");
|
||||
|
||||
const auto numerals = digits (t, spec.base);
|
||||
const auto characters = numerals + (spec.positive_char ? 1 : 0);
|
||||
|
@ -167,7 +167,7 @@ main (void)
|
||||
CHECK_THROW("%i", conversion_error, nullptr);
|
||||
|
||||
CHECK_THROW("%hhi", length_error, (long long)1);
|
||||
CHECK_THROW("%lli", length_error, (signed char)1);
|
||||
//CHECK_THROW("%lli", length_error, (signed char)1);
|
||||
|
||||
CHECK_THROW("%u", conversion_error, 1.);
|
||||
CHECK_THROW("%u", conversion_error, "foo");
|
||||
@ -176,7 +176,7 @@ main (void)
|
||||
CHECK_THROW("%u", conversion_error, nullptr);
|
||||
|
||||
CHECK_THROW("%hhu", length_error, (unsigned long long)1);
|
||||
CHECK_THROW("%llu", length_error, (unsigned char)1);
|
||||
//CHECK_THROW("%llu", length_error, (unsigned char)1);
|
||||
|
||||
CHECK_THROW("%f", conversion_error, 1u);
|
||||
CHECK_THROW("%f", conversion_error, "foo");
|
||||
|
Loading…
Reference in New Issue
Block a user