AVR C Runtime Library - Bugs: bug #32322, snprintf() Hex conversion field...
You are not allowed to post comments on this tracker with your current authentication level.
bug #32322: snprintf() Hex conversion field width specifiers malfunction
Submitter: | Rick M <rmann> | ||
Submitted: | Tue 01 Feb 2011 11:29:26 PM UTC | ||
Category: | Library | Severity: | 3 - Normal |
Priority: | 5 - Normal | Item Group: | libc code |
Status: | Invalid | Assigned to: | joerg_wunsch |
Percent Complete: | 0% | Open/Closed: | Closed |
Release: | 1.6.7 | Fixed Release: | None |
Wed 02 Feb 2011 10:15:32 AM UTC, comment #1: |
Joerg Wunsch <joerg_wunsch> |
Tue 01 Feb 2011 11:29:26 PM UTC, original submission:
There are numerous errors around the minimum field with specifier and padding with leading zeros. The test case below is the result of using the floating-point (full) version
|
Rick M <rmann> |
No files currently attached
Depends on the following items: None found
Items that depend on this one: None found
Follow 3 latest changes.
Date | Changed by | Updated Field | Previous Value | => | Replaced by |
---|---|---|---|---|---|
2011-02-02 | joerg_wunsch | Status | None | Invalid | |
Assigned to | None | joerg_wunsch | |||
Open/Closed | Open | Closed |
Powered by Savane 3.13-d3ae.
Corresponding source code
No bug involved (apart from the obvious bug that you supply the
arguments for sprintf() yet try to call snprintf()),
The field width includes everything that is eventually generated by
the format specifier, so the "0x" is always included in the field
width, and already occupies the entire output field except in the 0
case. Any actual data to be formatted thus has to overflow the output
field.
The 0 case is different, as ISO/IEC 9899:1999 requires the
implementation to not generate the 0x prefix in that case:
# The result is converted to an ``alternative form''. [...] For x (or
X) conversion, a nonzero result has 0x (or 0X) prefixed to it. [...]
Thus, the output field is sufficient, and as the '0' flag has been
given, it is zero-padded to the left, resulting in "00".