# New Ticket Created by  Andy Dougherty 
# Please include the string:  [perl #39244]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=39244 >


Parrot's I and N registers are initialized to 0, but only for DEBUGGING
builds.  For non-debugging builds, registers often, but not always, end
up as zero.  This leads to subtle errors -- I have found and patched
several spots in the test suite where test files assumed registers were
zeroed.  I suspect there are more errors waiting to be discovered.

I don't know what the ultimate intent is, but having initialization
depend on whether or not parrot was built with -DDEBUGGING doesn't seem
like a good long-term plan.

The first patch here simply removes the DEBUGGING conditional.  This
way, registers are automatically zeroed, unless the user uses the -D40
flag.  

The second patch changes the initial value to a different non-zero
value.  This is useful for ferreting out hidden assumptions.  If the
ultimate intent is to guarantee initialization to 0, then this second
patch should probably not be applied.  However, if the intent is not to
guarantee initialization, then I'd recommend something like this second
patch be put in place, at least for a while, to ensure no programs are
relying on automatic initialization.


--- parrot-current/src/register.c       2006-05-11 09:01:03.960002000 -0400
+++ parrot-andy/src/register.c  2006-05-11 11:18:59.000000000 -0400
@@ -202,7 +202,6 @@
     for (i = 0; i < ctx->n_regs_used[REGNO_STR]; i++) {
         CTX_REG_STR(ctx, i) = NULL;
     }
-#ifndef NDEBUG
     for (i = 0; i < ctx->n_regs_used[REGNO_INT]; i++) {
         /* depending on -D40 we set int, num to garbage or zero
          */
@@ -224,7 +223,6 @@
             CTX_REG_NUM(ctx, i) = 0.0;
         }
     }
-#endif
 }
 
 static void
--- parrot-current/src/register.c       2006-05-11 11:18:59.000000000 -0400
+++ parrot-andy/src/register.c  2006-05-11 11:20:40.000000000 -0400
@@ -203,24 +203,24 @@
         CTX_REG_STR(ctx, i) = NULL;
     }
     for (i = 0; i < ctx->n_regs_used[REGNO_INT]; i++) {
-        /* depending on -D40 we set int, num to garbage or zero
+        /* depending on -D40 we set int, num to different garbage values
          */
         if (Interp_debug_TEST(interpreter, PARROT_REG_DEBUG_FLAG)) {
             /* TODO better use rand values */
             CTX_REG_INT(ctx, i) = -999;
         }
         else {
-            CTX_REG_INT(ctx, i) = 0;
+            CTX_REG_INT(ctx, i) = -888;
         }
     }
     for (i = 0; i < ctx->n_regs_used[REGNO_NUM]; i++) {
-        /* depending on -D40 we set int, num to garbage or zero
+        /* depending on -D40 we set int, num to different garbage values
          */
         if (Interp_debug_TEST(interpreter, PARROT_REG_DEBUG_FLAG)) {
             CTX_REG_NUM(ctx, i) = -99.9;
         }
         else {
-            CTX_REG_NUM(ctx, i) = 0.0;
+            CTX_REG_NUM(ctx, i) = -88.8;
         }
     }
 }

-- 
    Andy Dougherty              [EMAIL PROTECTED]

Reply via email to