[PATCH] Fix a warning in haifa-sched.c

Jeff Law law@redhat.com
Sun Jan 17 21:13:00 GMT 2016


On 01/17/2016 10:59 AM, Jakub Jelinek wrote:
> Hi!
>
> During profiledbootstrap, I'm seeing:
> ../../gcc/system.h: In function 'void autopref_multipass_init(const rtx_insn*, int)':
> ../../gcc/system.h:367:29: warning: 'max_offset' may be used uninitialized in this function [-Wmaybe-uninitialized]
>   #define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
>                               ^
> ../../gcc/haifa-sched.c:5603:11: note: 'max_offset' was declared here
>         int max_offset;
>             ^~~~~~~~~~
> and similarly for min_offset.  The warning is a false positive just because
> the compiler can't know that a PARALLEL should never have zero XVECLEN (pat, 0).
> prev_base which is also set during the first iteration and thus not set
> if n_elems is 0 already have an initializer for this reason.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2016-01-17  Jakub Jelinek  <jakub@redhat.com>
>
> 	* haifa-sched.c (autopref_multipass_init): Work around
> 	-Wmaybe-uninitialized warning.
OK.  I was carrying a similar patch locally.  The difference is I used 
INT_MAX for min_offset and INT_MIN for max_offset, just for extra safety.

Jeff



More information about the Gcc-patches mailing list