This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] rl78: GCC false warning workaround


Hi,

$ CFLAGS=-O2 ./configure --target=rl78-elf; make
[...]
make[4]: Entering directory `/home/jkratoch/redhat/gdb-test-array/opcodes'
rl78-dis.c: In function ‘print_insn_rl78’:
rl78-dis.c:223:11: error: array subscript is above array bounds [-Werror=array-bounds]
   if (oper->use_es && indirect_type (oper->type))
           ^
cc1: all warnings being treated as errors

PASS: gcc (GCC) 4.7.3 20130221 (prerelease)
FAIL: gcc-4.8.0-1.fc19.x86_64
FAIL: gcc (GCC) 4.9.0 20130410 (experimental)

I have found tracked it by GCC, for example:
	[4.8/4.9 regression] Bogus -Warray-bounds warning
	http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273

As such GCCs are out there I would prefer to use an alternative form in bfd.
TBH I find the patch below even more readable.

Not tested.


Thanks,
Jan


opcodes/
2013-04-10  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* rl78-dis.c (print_insn_rl78): Use alternative form as a GCC false
	warning workaround.

diff --git a/opcodes/rl78-dis.c b/opcodes/rl78-dis.c
index 1ceee8d..7d1eab4 100644
--- a/opcodes/rl78-dis.c
+++ b/opcodes/rl78-dis.c
@@ -217,7 +217,7 @@ print_insn_rl78 (bfd_vma addr, disassemble_info * dis)
 
 	    case '0':
 	    case '1':
-	      oper = opcode.op + *s - '0';
+	      oper = *s == '0' ? &opcode.op[0] : &opcode.op[1];
 	    if (do_es)
 	      {
 		if (oper->use_es && indirect_type (oper->type))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]