[PATCH v2] CSKY: Fix sprintf argument overlaping destination error.

Simon Marchi simon.marchi@efficios.com
Wed Sep 9 15:50:23 GMT 2020


On 2020-09-09 11:41 a.m., Cooper Qu wrote:
> Fix compilation failure when building with gcc-10:
> csky-dis.c:678:2: error: ‘sprintf’ argument 3 overlaps destination object ‘str’
> csky-dis.c:650:2: error: ‘sprintf’ argument 3 overlaps destination object ‘str’

Just use the full snippet that I pasted in my original message:

make[4]: Entering directory '/home/smarchi/build/binutils-gdb/opcodes'
/bin/bash ./libtool  --tag=CC   --mode=compile ccache gcc-10 -DHAVE_CONFIG_H -I. -I/home/smarchi/src/binutils-gdb/opcodes  -I. -I/home/smarchi/src/binutils-gdb/opcodes -I../bfd -I/home/smarchi/src/binutils-gdb/opcodes/../include -I/home/smarchi/src/binutils-gdb/opcodes/../bfd    -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Werror -g3 -O0 -I/opt/elfutils/include -MT csky-dis.lo -MD -MP -MF .deps/csky-dis.Tpo -c -o csky-dis.lo /home/smarchi/src/binutils-gdb/opcodes/csky-dis.c
libtool: compile:  ccache gcc-10 -DHAVE_CONFIG_H -I. -I/home/smarchi/src/binutils-gdb/opcodes -I. -I/home/smarchi/src/binutils-gdb/opcodes -I../bfd -I/home/smarchi/src/binutils-gdb/opcodes/../include -I/home/smarchi/src/binutils-gdb/opcodes/../bfd -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Werror -g3 -O0 -I/opt/elfutils/include -MT csky-dis.lo -MD -MP -MF .deps/csky-dis.Tpo -c /home/smarchi/src/binutils-gdb/opcodes/csky-dis.c -o csky-dis.o
/home/smarchi/src/binutils-gdb/opcodes/csky-dis.c: In function ‘csky_output_operand’:
/home/smarchi/src/binutils-gdb/opcodes/csky-dis.c:678:2: error: ‘sprintf’ argument 3 overlaps destination object ‘str’ [-Werror=restrict]
  678 |  sprintf (str, "%s%lf\t// imm9:%4ld, imm4:%2ld", str, d, imm8, imm4);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/smarchi/src/binutils-gdb/opcodes/csky-dis.c:650:2: error: ‘sprintf’ argument 3 overlaps destination object ‘str’ [-Werror=restrict]
  650 |  sprintf (str, "%s%f\t// imm9:%4d, imm4:%2d", str, f, imm8, imm4);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Simon


More information about the Binutils mailing list