This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: [PATCH] Avoid uninitialized warning in i386.c


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;

> 2013-12-18  Marek Polacek  <polacek@redhat.com>
> 
> 	* config/i386/i386.c (ix86_parse_stringop_strategy_string): Initialize
> 	alg to 0.
> 
> --- gcc/config/i386/i386.c.mp	2013-12-18 13:38:21.908138307 +0100
> +++ gcc/config/i386/i386.c	2013-12-18 13:38:41.417214628 +0100
> @@ -2856,7 +2856,7 @@ ix86_parse_stringop_strategy_string (cha
>    do
>      {
>        int maxs;
> -      stringop_alg alg;
> +      stringop_alg alg = (stringop_alg) 0;
>        char alg_name[128];
>        char align[16];
>        next_range_str = strchr (curr_range_str, ',');

	Jakub


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