diff mbox

i386.c: Initialize function pointers to NULL to prevent, -Wmaybe-uninitialized

Message ID be6326a8-097c-3267-4c17-7080a8d61c8e@suse.cz
State New
Headers show

Commit Message

Martin Liška Nov. 23, 2016, 10:06 a.m. UTC
I see broken bootstrap due to:

.././../gcc/config/i386/i386.c: In function ‘rtx_def* ix86_expand_builtin(tree, rtx, rtx, machine_mode, int)’:
.././../gcc/config/i386/i386.c:38407:18: error: ‘fcn’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
        emit_insn (fcn (target, accum, wide_reg, mem));
        ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Thus I'm suggesting to initialize the variable (and 2 which are used in a very similar manner) to NULL.

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Ready to be installed?
Martin

Comments

Jakub Jelinek Nov. 23, 2016, 10:12 a.m. UTC | #1
On Wed, Nov 23, 2016 at 11:06:23AM +0100, Martin Liška wrote:
> I see broken bootstrap due to:

> 

> .././../gcc/config/i386/i386.c: In function ‘rtx_def* ix86_expand_builtin(tree, rtx, rtx, machine_mode, int)’:

> .././../gcc/config/i386/i386.c:38407:18: error: ‘fcn’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

>         emit_insn (fcn (target, accum, wide_reg, mem));

>         ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> 

> Thus I'm suggesting to initialize the variable (and 2 which are used in a very similar manner) to NULL.

> 

> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.


That is not very relevant for i386.c change, is it?

> 2016-11-22  Martin Liska  <mliska@suse.cz>

> 

> 	* config/i386/i386.c: Initialize function pointers to NULL.

> ---

>  gcc/config/i386/i386.c | 6 +++---

>  1 file changed, 3 insertions(+), 3 deletions(-)

> 

> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c

> index 25f0446..a373fcf 100644

> --- a/gcc/config/i386/i386.c

> +++ b/gcc/config/i386/i386.c

> @@ -38218,9 +38218,9 @@ rdseed_step:

>        && fcode <= IX86_BUILTIN__BDESC_ARGS2_LAST)

>      {

>        i = fcode - IX86_BUILTIN__BDESC_ARGS2_FIRST;

> -      rtx (*fcn) (rtx, rtx, rtx, rtx);

> -      rtx (*fcn_mask) (rtx, rtx, rtx, rtx, rtx);

> -      rtx (*fcn_maskz) (rtx, rtx, rtx, rtx, rtx, rtx);

> +      rtx (*fcn) (rtx, rtx, rtx, rtx) = NULL;

> +      rtx (*fcn_mask) (rtx, rtx, rtx, rtx, rtx) = NULL;

> +      rtx (*fcn_maskz) (rtx, rtx, rtx, rtx, rtx, rtx) = NULL;

>        int masked = 1;

>        machine_mode mode, wide_mode, nar_mode;


      nar_mode  = V4SFmode;
      mode      = V16SFmode;   
      wide_mode = V64SFmode;
      fcn_mask  = gen_avx5124fmaddps_4fmaddps_mask;
      fcn_maskz = gen_avx5124fmaddps_4fmaddps_maskz;

follows this immediately, so there is no point in setting fcn_mask
and fcn_maskz to NULL.

	Jakub
Martin Liška Nov. 23, 2016, 10:20 a.m. UTC | #2
On 11/23/2016 11:12 AM, Jakub Jelinek wrote:
> On Wed, Nov 23, 2016 at 11:06:23AM +0100, Martin Liška wrote:

>> I see broken bootstrap due to:

>>

>> .././../gcc/config/i386/i386.c: In function ‘rtx_def* ix86_expand_builtin(tree, rtx, rtx, machine_mode, int)’:

>> .././../gcc/config/i386/i386.c:38407:18: error: ‘fcn’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

>>         emit_insn (fcn (target, accum, wide_reg, mem));

>>         ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

>>

>> Thus I'm suggesting to initialize the variable (and 2 which are used in a very similar manner) to NULL.

>>

>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

> 

> That is not very relevant for i386.c change, is it?


Sorry, I've used automatic testing. I'll re-trigger x86_64 bootstrap.

> 

>> 2016-11-22  Martin Liska  <mliska@suse.cz>

>>

>> 	* config/i386/i386.c: Initialize function pointers to NULL.

>> ---

>>  gcc/config/i386/i386.c | 6 +++---

>>  1 file changed, 3 insertions(+), 3 deletions(-)

>>

>> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c

>> index 25f0446..a373fcf 100644

>> --- a/gcc/config/i386/i386.c

>> +++ b/gcc/config/i386/i386.c

>> @@ -38218,9 +38218,9 @@ rdseed_step:

>>        && fcode <= IX86_BUILTIN__BDESC_ARGS2_LAST)

>>      {

>>        i = fcode - IX86_BUILTIN__BDESC_ARGS2_FIRST;

>> -      rtx (*fcn) (rtx, rtx, rtx, rtx);

>> -      rtx (*fcn_mask) (rtx, rtx, rtx, rtx, rtx);

>> -      rtx (*fcn_maskz) (rtx, rtx, rtx, rtx, rtx, rtx);

>> +      rtx (*fcn) (rtx, rtx, rtx, rtx) = NULL;

>> +      rtx (*fcn_mask) (rtx, rtx, rtx, rtx, rtx) = NULL;

>> +      rtx (*fcn_maskz) (rtx, rtx, rtx, rtx, rtx, rtx) = NULL;

>>        int masked = 1;

>>        machine_mode mode, wide_mode, nar_mode;

> 

>       nar_mode  = V4SFmode;

>       mode      = V16SFmode;   

>       wide_mode = V64SFmode;

>       fcn_mask  = gen_avx5124fmaddps_4fmaddps_mask;

>       fcn_maskz = gen_avx5124fmaddps_4fmaddps_maskz;

> 

> follows this immediately, so there is no point in setting fcn_mask

> and fcn_maskz to NULL.


Will remove zeroing of these two.

Martin

> 

> 	Jakub

>
diff mbox

Patch

From 0a8dfb71f0f9c6359428d908b88e99f3146f69e4 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Tue, 22 Nov 2016 11:12:14 +0100
Subject: [PATCH] i386.c: Initialize function pointers to NULL to prevent
 -Wmaybe-uninitialized

gcc/ChangeLog:

2016-11-22  Martin Liska  <mliska@suse.cz>

	* config/i386/i386.c: Initialize function pointers to NULL.
---
 gcc/config/i386/i386.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 25f0446..a373fcf 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -38218,9 +38218,9 @@  rdseed_step:
       && fcode <= IX86_BUILTIN__BDESC_ARGS2_LAST)
     {
       i = fcode - IX86_BUILTIN__BDESC_ARGS2_FIRST;
-      rtx (*fcn) (rtx, rtx, rtx, rtx);
-      rtx (*fcn_mask) (rtx, rtx, rtx, rtx, rtx);
-      rtx (*fcn_maskz) (rtx, rtx, rtx, rtx, rtx, rtx);
+      rtx (*fcn) (rtx, rtx, rtx, rtx) = NULL;
+      rtx (*fcn_mask) (rtx, rtx, rtx, rtx, rtx) = NULL;
+      rtx (*fcn_maskz) (rtx, rtx, rtx, rtx, rtx, rtx) = NULL;
       int masked = 1;
       machine_mode mode, wide_mode, nar_mode;
 
-- 
2.10.2