https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77762
Bug ID: 77762 Summary: Incorrect destination buffer length in -Wformat-length warning Product: gcc Version: 7.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: fw at gcc dot gnu.org CC: msebor at gcc dot gnu.org Target Milestone: --- Created attachment 39703 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39703&action=edit dbg_log.c The attached test case, extracted from nscd/dbg_log.c in glibc, prints (when compiled with -O2 -Wall): dbg_log.c: In function ‘dbg_log’: dbg_log.c:11:10: warning: specified size 512 exceeds the size 1 of the destination object [-Wformat-length=] return __builtin___vsnprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ __bos (__s), __fmt, __ap); ~~~~~~~~~~~~~~~~~~~~~~~~~ This appears to be different from bug 77743 because GCC should not have buffer length information in this case.