-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Labels
area: C LibraryC Standard LibraryC Standard Libraryarea: newlibNewlib C Standard LibraryNewlib C Standard LibrarybugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: highHigh impact/importance bugHigh impact/importance bug
Milestone
Description
case 'h':
#ifdef _WANT_IO_C99_FORMATS
if (*fmt == 'h') {
fmt++;
flags |= CHARINT;
} else
#endifNoting that the newlib-nano build does not support the hh modifier, the PRIx8 inttypes should not resolve to hh*; instead, they should resolve to one of the closest types (e.g. h*).
To Reproduce
Run the following code with CONFIG_NEWLIB_LIBC=y and CONFIG_NEWLIB_LIBC_NANO=y:
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
void main(void)
{
volatile uint8_t a = 92;
volatile uint8_t b = 254;
volatile uint16_t c = 4883;
printf("%hhu.%hhu.%hu\n", a, b, c);
printf("%%" PRIu8 "\n");
}Because the hh modifier is not supported with the newlib-nano, the output is as follows:
hu.hu.92
%hhu
Note that PRIu8 resolves to hhu, which is not supported; thereby, rendering PRIx8 inttypes unusable with the newlib-nano.
Expected behavior
When CONFIG_NEWLIB_LIBC_NANO=y, PRIx8 inttypes resolve to %h*, which is the closest to %hh*.
Impact
PRIx8 inttypes are unusable with the newlib-nano.
Environment (please complete the following information):
- OS: Ubuntu 20.04
- Toolchain: Zephyr SDK 0.14.1
- Commit SHA: d5e7732
Additional context
- This problem was originally reported and discussed in Fix version string formatting #45329 (comment)
- The exact same problem is observed with the GNU Arm Embedded toolchain (because the Zephyr SDK has tried to replicate the GNU Arm Embedded build configurations until now).
Metadata
Metadata
Assignees
Labels
area: C LibraryC Standard LibraryC Standard Libraryarea: newlibNewlib C Standard LibraryNewlib C Standard LibrarybugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: highHigh impact/importance bugHigh impact/importance bug