https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79275
Bug ID: 79275 Summary: -Wformat-overflow false positive exceeding INT_MAX in glibc sysdeps/posix/tempname.c Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- As reported on libc-alpha (https://sourceware.org/ml/libc-alpha/2017-01/msg00541.html) the following test case triggers a false positive -Wformat-overflow warning: $ cat a.c && gcc -O2 -S -Wall -m32 a.c typedef __SIZE_TYPE__ size_t; void f (char *dst, size_t n, const char *s) { if (n < 2 || __INT_MAX__ - 2 < n) n = 2; __builtin_sprintf (dst, "%.*s %.*s", (int)n, s, (int)n, s); } a.c: In function ‘f’: a.c:8:33: warning: ‘%.*s’ directive output between 0 and 2147483645 bytes may cause result to exceed ‘INT_MAX’ [-Wformat-overflow=] __builtin_sprintf (dst, "%.*s %.*s", (int)n, s, (int)n, s); ^~~~