This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Avoid uninitialized warning in i386.c
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 18 Dec 2013 14:45:12 +0100
- Subject: Re: [PATCH] Avoid uninitialized warning in i386.c
- Authentication-results: sourceware.org; auth=none
- References: <20131218133944 dot GY11710 at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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