On 2017-07-07 09:35 -0600, Martin Sebor wrote: > On 07/07/2017 07:05 AM, Basin Ilya wrote: > > #include <stdio.h> > > > > extern struct { > > char s[142]; > > } x; > > > > extern char s[142]; > > > > int main(int argc, char *argv[]) { > > char buf[12]; > > sprintf(buf, "%c%s", 'x', x.s); // why warning? > > sprintf(buf, "%s", x.s); // why no warning then? > > sprintf(buf, "%c%s", 'x', s); // why no warning then? > > return 0; > > } > With GCC 8 I get a warning for the second call to sprintf for > the same reason at both -Wformat-overflow levels. I'm not sure > what prevents it in your case. Please open a new bug for it and > either attach the translation unit for your test case (obtained > by preprocessing it with with -E) or remove the #include and > declare sprintf or use __builtin_sprintf. (This should tell > us if the sprintf declaration in <stdio.h> is causing it.) No. Using __builtin_sprintf still produces no warning with GCC 7. I think it's a GCC 7 bug. -- Xi Ruoyao <ryxi@xxxxxxxxxxxxxxxxx> School of Aerospace Science and Technology, Xidian University