RISC-V: Suppress riscv-selftests.cc warning.

Message ID 20220917005949.263893-1-juzhe.zhong@rivai.ai
State Deferred, archived
Headers
Series RISC-V: Suppress riscv-selftests.cc warning. |

Commit Message

钟居哲 Sept. 17, 2022, 12:59 a.m. UTC
  From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>

This patch is a fix patch for:
https://gcc.gnu.org/pipermail/gcc-patches/2022-September/601643.html

Suppress the warning as follows:

../../../riscv-gcc/gcc/poly-int.h: In function
‘poly_int64 eval_value(rtx, std::map<unsigned int, rtx_def*>&)’:
../../../riscv-gcc/gcc/poly-int.h:845:48: warning:
‘*((void*)& op2_val +8)’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
     POLY_SET_COEFF (C, r, i, NCa (a.coeffs[i]) + b.coeffs[i]);
                                                ^
../../../riscv-gcc/gcc/config/riscv/riscv-selftests.cc:74:23:
note: ‘*((void*)& op2_val +8)’ was declared here
   poly_int64 op1_val, op2_val;

gcc/ChangeLog:

        * config/riscv/riscv-selftests.cc (eval_value): Add initial value.

---
 gcc/config/riscv/riscv-selftests.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Kito Cheng Sept. 23, 2022, 3:35 p.m. UTC | #1
Committed, but squashed changes to "RISC-V: Support poly move
manipulation and selftests." instead of a standalone commit.

On Sat, Sep 17, 2022 at 9:00 AM <juzhe.zhong@rivai.ai> wrote:
>
> From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
>
> This patch is a fix patch for:
> https://gcc.gnu.org/pipermail/gcc-patches/2022-September/601643.html
>
> Suppress the warning as follows:
>
> ../../../riscv-gcc/gcc/poly-int.h: In function
> ‘poly_int64 eval_value(rtx, std::map<unsigned int, rtx_def*>&)’:
> ../../../riscv-gcc/gcc/poly-int.h:845:48: warning:
> ‘*((void*)& op2_val +8)’ may be used uninitialized
> in this function [-Wmaybe-uninitialized]
>      POLY_SET_COEFF (C, r, i, NCa (a.coeffs[i]) + b.coeffs[i]);
>                                                 ^
> ../../../riscv-gcc/gcc/config/riscv/riscv-selftests.cc:74:23:
> note: ‘*((void*)& op2_val +8)’ was declared here
>    poly_int64 op1_val, op2_val;
>
> gcc/ChangeLog:
>
>         * config/riscv/riscv-selftests.cc (eval_value): Add initial value.
>
> ---
>  gcc/config/riscv/riscv-selftests.cc | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/config/riscv/riscv-selftests.cc b/gcc/config/riscv/riscv-selftests.cc
> index 167cd47c880..490b6ed6b8e 100644
> --- a/gcc/config/riscv/riscv-selftests.cc
> +++ b/gcc/config/riscv/riscv-selftests.cc
> @@ -71,7 +71,8 @@ eval_value (rtx x, std::map<unsigned, rtx> &regno_to_rtx)
>    unsigned regno = REGNO (x);
>    expr = regno_to_rtx[regno];
>
> -  poly_int64 op1_val, op2_val;
> +  poly_int64 op1_val = 0;
> +  poly_int64 op2_val = 0;
>    if (UNARY_P (expr))
>      {
>        op1_val = eval_value (XEXP (expr, 0), regno_to_rtx);
> --
> 2.36.1
>
  

Patch

diff --git a/gcc/config/riscv/riscv-selftests.cc b/gcc/config/riscv/riscv-selftests.cc
index 167cd47c880..490b6ed6b8e 100644
--- a/gcc/config/riscv/riscv-selftests.cc
+++ b/gcc/config/riscv/riscv-selftests.cc
@@ -71,7 +71,8 @@  eval_value (rtx x, std::map<unsigned, rtx> &regno_to_rtx)
   unsigned regno = REGNO (x);
   expr = regno_to_rtx[regno];
 
-  poly_int64 op1_val, op2_val;
+  poly_int64 op1_val = 0;
+  poly_int64 op2_val = 0;
   if (UNARY_P (expr))
     {
       op1_val = eval_value (XEXP (expr, 0), regno_to_rtx);