https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78910
Bug ID: 78910 Summary: [7 Regression] Wrong print-return-value for a negative number Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: marxin at gcc dot gnu.org CC: msebor at gcc dot gnu.org Target Milestone: --- The issue can be seen in ICU package test-suite, in section decorated: "Get really crazy with the formatting." $ cat /tmp/printf-test.c int main() { char b[128]; int l = __builtin_sprintf (b, "%.2d", -1); __builtin_printf ("b: '%s', length: %d\n", b, l); if (l != 3) __builtin_abort (); return 0; } $ gcc /tmp/printf-test.c -O2 && ./a.out b: '-01', length: 2 Aborted (core dumped)