This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
hv.c: silence compiler warning
authorYves Orton <demerphq@gmail.com>
Thu, 1 Jun 2017 14:30:34 +0000 (16:30 +0200)
committerYves Orton <demerphq@gmail.com>
Thu, 1 Jun 2017 15:17:34 +0000 (17:17 +0200)
hv.c: In function ‘Perl_hv_undef_flags’:
hv.c:2053:35: warning: ‘orig_ix’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             PL_tmps_stack[orig_ix] = &PL_sv_undef;

The warning is bogus, as we only use orig_ix if "save" is true,
and if "save" is true we will have initialized orig_ix. However
initializing it in the first place avoids any issue

hv.c

diff --git a/hv.c b/hv.c
index 8acf33a..f372728 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -1955,7 +1955,7 @@ Perl_hv_undef_flags(pTHX_ HV *hv, U32 flags)
 {
     XPVHV* xhv;
     bool save;
-    SSize_t orig_ix;
+    SSize_t orig_ix = PL_tmps_ix; /* silence compiler warning about unitialized vars */
 
     if (!hv)
        return;