boostorg / boostorg/format

Enhancement: format (u)int8 types correctly to number, if formatted with %d, &i, %u

Open
#60 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
31
Forks
53
PR merge metrics
No merged PRs in 30d

Description

If I try to format a (u)int8 number, Boost.Format considers this as (unsigned) char, even if I use `%d`, `%i` or `%u`.

[This is a known and rather old issue](http://boost.2283326.n4.nabble.com/format-show-uint8-t-as-a-number-not-a-char-td2563278.html).

The workaround is to cast the number to (u)int32, before formatting.

Nevertheless the current behavior leads to very subtle bugs, because the developer has to check the type of the number to be printed very carefully.

Plain `printf` handles (u)int8 numbers in combination with `%d`, `%i` or `%u` correctly.

Boost version: 1.68 (32bit)
Compiler: MSVC 15.8

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.