This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch fixing a rare genautomata bug
- From: Vladimir Makarov <vmakarov at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 29 Apr 2003 18:47:23 -0400
- Subject: Patch fixing a rare genautomata bug
I've run into a rare genautomata bug. An undefined value used for
table could bigger than maximal table element value. The type of
elements is defined from the maximal element value. So the undefined
value can be truncated if it is out of range of table element type.
The following patch fixes the problem. The patch is very safe. It has
been tested on regression tests and bootstrap for x86 and ia64.
I've just committed the patch into the main line.
Vlad
2003-04-29 Vladimir Makarov <vmakarov@redhat.com>
* genautomata.c (add_vect): Check undefined value for range type
too.
Index: genautomata.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/genautomata.c,v
retrieving revision 1.39
diff -c -p -r1.39 genautomata.c
*** genautomata.c 13 Mar 2003 03:48:27 -0000 1.39
--- genautomata.c 29 Apr 2003 21:15:52 -0000
*************** output_translate_vect (automaton)
*** 7670,7676 ****
VLA_HWINT_CREATE (translate_vect, 250, "translate vector");
VLA_HWINT_EXPAND (translate_vect, description->insns_num);
! for (insn_value = 0; insn_value <= description->insns_num; insn_value++)
/* Undefined value */
VLA_HWINT (translate_vect, insn_value) = automaton->insn_equiv_classes_num;
for (ainsn = automaton->ainsn_list; ainsn != NULL; ainsn = ainsn->next_ainsn)
--- 7670,7676 ----
VLA_HWINT_CREATE (translate_vect, 250, "translate vector");
VLA_HWINT_EXPAND (translate_vect, description->insns_num);
! for (insn_value = 0; insn_value < description->insns_num; insn_value++)
/* Undefined value */
VLA_HWINT (translate_vect, insn_value) = automaton->insn_equiv_classes_num;
for (ainsn = automaton->ainsn_list; ainsn != NULL; ainsn = ainsn->next_ainsn)
*************** add_vect (tab, vect_num, vect, vect_leng
*** 7885,7890 ****
--- 7885,7894 ----
tab->min_comb_vect_el_value = vect [vect_index];
check_vect_start [comb_vect_index + vect_index] = vect_num;
}
+ if (tab->max_comb_vect_el_value < undefined_vect_el_value)
+ tab->max_comb_vect_el_value = undefined_vect_el_value;
+ if (tab->min_comb_vect_el_value > undefined_vect_el_value)
+ tab->min_comb_vect_el_value = undefined_vect_el_value;
if (tab->max_base_vect_el_value < comb_vect_index)
tab->max_base_vect_el_value = comb_vect_index;
if (tab->min_base_vect_el_value > comb_vect_index)