https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77721
--- Comment #7 from Dmitry G. Dyachenko <dimhen at gmail dot com> --- Sounds like gcc-8.0.1 PASS for me r257061 FAIL r258034 PASS r12-5546 PASS $ ~/arch-gcc/SVN/gcc_258034/bin/gcc --version gcc (GCC) 8.0.1 20180227 (experimental) [trunk revision 258034] $ ~/arch-gcc/SVN/gcc_258034/bin/gcc -O2 -S -Wall -Woverflow -Wconversion -Wpedantic -Wformat-truncation=2 -xc x.c $ cat x.c int snprintf (char*, __SIZE_TYPE__, const char*, ...); void foo(unsigned j, char *p) { if(j > 999) return; snprintf(p, 4, "%3u", j); } void bar(int j, char *p) { const unsigned k = (unsigned) j; if(k > 999) return; snprintf(p, 4, "%3u", k); }