This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
switch-local variables are a bad idea.
authorJarkko Hietaniemi <jhi@iki.fi>
Thu, 27 Nov 2014 16:46:27 +0000 (11:46 -0500)
committerJarkko Hietaniemi <jhi@iki.fi>
Thu, 27 Nov 2014 16:46:27 +0000 (11:46 -0500)
(another weirdness is that the mg and stash are not explicitly
used in the code, so the macros must be assuming their existence.)

(clang -Wunreachable-code)

pp.c

diff --git a/pp.c b/pp.c
index 621377f..5abe647 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -6229,9 +6229,10 @@ PP(pp_refassign)
     if (bad)
        /* diag_listed_as: Assigned value is not %s reference */
        DIE(aTHX_ "Assigned value is not a%s reference", bad);
+    {
+    MAGIC *mg;
+    HV *stash;
     switch (left ? SvTYPE(left) : 0) {
-       MAGIC *mg;
-       HV *stash;
     case 0:
     {
        SV * const old = PAD_SV(ARGTARG);
@@ -6267,6 +6268,7 @@ PP(pp_refassign)
     /* XXX else can weak references go stale before they are read, e.g.,
        in leavesub?  */
     RETURN;
+    }
 }
 
 PP(pp_lvref)