In stage2 of bootstrap-O1, the code that warns if sprintf might overflow its output buffer cannot tell that an unsigned value narrowed to 16 bits will fit in 4 bytes with %4x.
I couldn't find a better way to avoid the warning at -O1 than growing the buffer so that there's no doubt the output will fit. Regstrapped on x86_64-linux-gnu and i686-linux-gnu. Ok to install? for gcc/c-family/ChangeLog * c-pretty-print.c (pp_c_tree_decl_identifier): Grow static buffer to avoid false-positive warning. --- gcc/c-family/c-pretty-print.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c index c32d0a0..dc6856a 100644 --- a/gcc/c-family/c-pretty-print.c +++ b/gcc/c-family/c-pretty-print.c @@ -2375,7 +2375,8 @@ pp_c_tree_decl_identifier (c_pretty_printer *pp, tree t) name = IDENTIFIER_POINTER (DECL_NAME (t)); else { - static char xname[8]; + /* xname[8] would do, but at -O1 we can't tell it's enough. */ + static char xname[12]; sprintf (xname, "<U%4x>", ((unsigned)((uintptr_t)(t) & 0xffff))); name = xname; } -- Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/ You must be the change you wish to see in the world. -- Gandhi Be Free! -- http://FSFLA.org/ FSF Latin America board member Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer