From 9c70b53cc39bd1347ed714e7a2e567a0c761246a Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Thu, 13 Jun 2019 02:09:58 -0700 Subject: [PATCH] intrinsics.c: In function 'mini_emit_inst_for_method': intrinsics.c:1580:11: warning: 'result' may be used uninitialized in this function [-Wmaybe-uninitialized] *dest = result; ~~~~~~^~~~~~~~ --- mono/mini/intrinsics.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/mono/mini/intrinsics.c b/mono/mini/intrinsics.c index 18b9d28f3d5..dbff85351c1 100644 --- a/mono/mini/intrinsics.c +++ b/mono/mini/intrinsics.c @@ -1462,7 +1462,7 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign * we avoid folding constants that when computed would raise an error, in * case the user code was expecting to get that error raised */ - if (fsig->param_count == 1 && args [0]->opcode == OP_R8CONST){ + if (fsig->param_count == 1 && args [0]->opcode == OP_R8CONST) { double source = *(double *)args [0]->inst_p0; int opcode = 0; const char *mname = cmethod->name; @@ -1471,63 +1471,63 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign if (c == 'A'){ if (strcmp (mname, "Abs") == 0 && fsig->params [0]->type == MONO_TYPE_R8) { opcode = OP_ABS; - } else if (strcmp (mname, "Asin") == 0){ + } else if (strcmp (mname, "Asin") == 0) { if (fabs (source) <= 1) opcode = OP_ASIN; - } else if (strcmp (mname, "Asinh") == 0){ + } else if (strcmp (mname, "Asinh") == 0) { opcode = OP_ASINH; - } else if (strcmp (mname, "Acos") == 0){ + } else if (strcmp (mname, "Acos") == 0) { if (fabs (source) <= 1) opcode = OP_ACOS; - } else if (strcmp (mname, "Acosh") == 0){ + } else if (strcmp (mname, "Acosh") == 0) { if (source >= 1) opcode = OP_ACOSH; - } else if (strcmp (mname, "Atan") == 0){ + } else if (strcmp (mname, "Atan") == 0) { opcode = OP_ATAN; - } else if (strcmp (mname, "Atanh") == 0){ + } else if (strcmp (mname, "Atanh") == 0) { if (fabs (source) < 1) opcode = OP_ATANH; } - } else if (c == 'C'){ + } else if (c == 'C') { if (strcmp (mname, "Cos") == 0) { if (!isinf (source)) opcode = OP_COS; - } else if (strcmp (mname, "Cbrt") == 0){ + } else if (strcmp (mname, "Cbrt") == 0) { opcode = OP_CBRT; - } else if (strcmp (mname, "Cosh") == 0){ + } else if (strcmp (mname, "Cosh") == 0) { opcode = OP_COSH; } - } else if (c == 'R'){ + } else if (c == 'R') { if (strcmp (mname, "Round") == 0) opcode = OP_ROUND; - } else if (c == 'S'){ + } else if (c == 'S') { if (strcmp (mname, "Sin") == 0) { if (!isinf (source)) opcode = OP_SIN; } else if (strcmp (mname, "Sqrt") == 0) { if (source >= 0) opcode = OP_SQRT; - } else if (strcmp (mname, "Sinh") == 0){ + } else if (strcmp (mname, "Sinh") == 0) { opcode = OP_SINH; } - } else if (c == 'T'){ + } else if (c == 'T') { if (strcmp (mname, "Tan") == 0){ if (!isinf (source)) opcode = OP_TAN; - } else if (strcmp (mname, "Tanh") == 0){ + } else if (strcmp (mname, "Tanh") == 0) { opcode = OP_TANH; } } if (opcode) { double *dest = (double *) mono_domain_alloc (cfg->domain, sizeof (double)); - double result; + double result = 0; MONO_INST_NEW (cfg, ins, OP_R8CONST); ins->type = STACK_R8; ins->dreg = mono_alloc_dreg (cfg, (MonoStackType) ins->type); ins->inst_p0 = dest; - switch (opcode){ + switch (opcode) { case OP_ABS: result = fabs (source); break; @@ -1576,6 +1576,8 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign case OP_TANH: result = tanh (source); break; + default: + g_error ("invalid opcode %d", (int)opcode); } *dest = result; MONO_ADD_INS (cfg->cbb, ins); -- 2.11.4.GIT