On Wed, Dec 18, 2013 at 02:45:12PM +0100, Jakub Jelinek wrote: > On Wed, Dec 18, 2013 at 02:39:44PM +0100, Marek Polacek wrote: > > Bootstrap with -fsanitize=undefined revealed that the alg variable > > may be used uninitialized. Or at least gcc thinks so. This patch > > initializes it to 0. > > > > Regtested/bootstrapped on x86_64-linux, ok for trunk? > > Do > stringop_alg alg = last_alg; > instead, or alternatively (perhaps better), remove the alg variable > altogether, just break; in the loop and set > input_ranges[n].alg = (stringop_alg) i;
Okay. Regtested/bootstrapped on x86_64-linux, ok now? 2013-12-18 Marek Polacek <pola...@redhat.com> * config/i386/i386.c (ix86_parse_stringop_strategy_string): Remove variable alg. Use index variable i directly. --- gcc/config/i386/i386.c.mp 2013-12-18 13:38:21.908138307 +0100 +++ gcc/config/i386/i386.c 2013-12-18 16:24:37.034353633 +0100 @@ -2856,7 +2856,6 @@ ix86_parse_stringop_strategy_string (cha do { int maxs; - stringop_alg alg; char alg_name[128]; char align[16]; next_range_str = strchr (curr_range_str, ','); @@ -2879,13 +2878,8 @@ ix86_parse_stringop_strategy_string (cha } for (i = 0; i < last_alg; i++) - { - if (!strcmp (alg_name, stringop_alg_names[i])) - { - alg = (stringop_alg) i; - break; - } - } + if (!strcmp (alg_name, stringop_alg_names[i])) + break; if (i == last_alg) { @@ -2896,7 +2890,7 @@ ix86_parse_stringop_strategy_string (cha } input_ranges[n].max = maxs; - input_ranges[n].alg = alg; + input_ranges[n].alg = (stringop_alg) i; if (!strcmp (align, "align")) input_ranges[n].noalign = false; else if (!strcmp (align, "noalign")) Marek