From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani
This doesn't work with GCC 7.=C2=A0 (Maybe it would work with GCC 8; th= e
release notes say that it is better at avoiding false positives.)=C2=A0 For=
integer specifiers like "%ld", the only thing I've found that= works
without enlarging the buffer is to cast the argument to a smaller
integer type.=C2=A0
For float specifiers li= ke "%3.1f", even using a small
type doesn't seem to work.=C2=A0 For example:
$ cat test.c
#include <stdio.h>
int
main ()
{
=C2=A0 =C2=A0char buffer[16];
=C2=A0 =C2=A0short a;
=C2=A0 =C2=A0snprintf (buffer, 16, "%3.1f", a);
}