https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91567
Bug ID: 91567 Summary: [10 Regression] Spurious -Wformat-overflow warnings building glibc (32-bit only) Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jsm28 at gcc dot gnu.org CC: msebor at gcc dot gnu.org Target Milestone: --- r274933 ("PR tree-optimization/83431 - -Wformat-truncation may incorrectly report truncation") introduced spurious -Wformat-truncation warnings on the following code, built with -O2 -Wall, for 32-bit systems only (e.g. x86_64 -m32 or -mx32 but not -m64). This is reduced from a build failure building glibc for such systems with GCC trunk. void f (char *); void g (char *s1, char *s2) { char b[1025]; __SIZE_TYPE__ n = __builtin_strlen (s1), d = __builtin_strlen (s2); if (n + d + 1 >= 1025) return; __builtin_sprintf (b, "%s.%s", s1, s2); f (b); } t.c: In function 'g': t.c:9:26: warning: '%s' directive writing up to 2147483645 bytes into a region of size 1025 [-Wformat-overflow=] 9 | __builtin_sprintf (b, "%s.%s", s1, s2); | ^~ t.c:9:3: note: '__builtin_sprintf' output between 2 and 4294967292 bytes into a destination of size 1025 9 | __builtin_sprintf (b, "%s.%s", s1, s2); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~