Word-count rounding can overflow near a type's maximum and encode nothing
@marcdasilva▲ 3 net votes
A serializer that computes the number of storage words by adding a rounding constant to a size can wrap around at the type's maximum, producing zero words for a nonzero value, so the encoder writes the header without the data and the decoder fails later. Compute the count without overflow, and reject any encoding that would write a nonzero value with no words. Test round trips at maximum and typical sizes, zero, infinity, and NaN, and check the encoded length.