From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joern Rennecke To: egcs@cygnus.com Subject: cast loss in final.c Date: Mon, 16 Mar 1998 20:44:00 -0000 Message-id: <199803170035.AAA09110@phal.cygnus.co.uk> X-SW-Source: 1998-03/msg00559.html I have just seen the apended change with cvs. I think it is wrong. If the operand number cannot be represented as an integer on the host, this can result in a negative value for c. By removing the cast to unsigned, such an error condition will will not be checked for, but result in a memory access to some peudo-random location. Thu Mar 12 08:37:02 1998 Manfred Hollstein ... * final.c (output_asm_insn): Don't cast insn_noperands to unsigned. Index: final.c =================================================================== RCS file: /egcs/carton/cvsfiles/egcs/gcc/final.c,v retrieving revision 1.26 retrieving revision 1.27 diff -p -r1.26 -r1.27 *** final.c 1998/03/11 07:12:25 1.26 --- final.c 1998/03/12 00:02:42 1.27 *************** output_asm_insn (template, operands) *** 3244,3250 **** if (! (*p >= '0' && *p <= '9')) output_operand_lossage ("operand number missing after %-letter"); ! else if (this_is_asm_operands && c >= (unsigned) insn_noperands) output_operand_lossage ("operand number out of range"); else if (letter == 'l') output_asm_label (operands[c]); --- 3244,3250 ---- if (! (*p >= '0' && *p <= '9')) output_operand_lossage ("operand number missing after %-letter"); ! else if (this_is_asm_operands && c >= insn_noperands) output_operand_lossage ("operand number out of range"); else if (letter == 'l') output_asm_label (operands[c]); *************** output_asm_insn (template, operands) *** 3277,3283 **** else if (*p >= '0' && *p <= '9') { c = atoi (p); ! if (this_is_asm_operands && c >= (unsigned) insn_noperands) output_operand_lossage ("operand number out of range"); else output_operand (operands[c], 0); --- 3277,3283 ---- else if (*p >= '0' && *p <= '9') { c = atoi (p); ! if (this_is_asm_operands && c >= insn_noperands) output_operand_lossage ("operand number out of range"); else output_operand (operands[c], 0);