This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Assert that PVGVs are never SvVALID() in the PVBM sense.
authorNicholas Clark <nick@ccl4.org>
Tue, 12 Dec 2006 21:00:37 +0000 (21:00 +0000)
committerNicholas Clark <nick@ccl4.org>
Tue, 12 Dec 2006 21:00:37 +0000 (21:00 +0000)
p4raw-id: //depot/perl@29536

gv.h
sv.h

diff --git a/gv.h b/gv.h
index 6ef8ee6..2463335 100644 (file)
--- a/gv.h
+++ b/gv.h
@@ -46,6 +46,7 @@ struct gp {
        (*({ GV * const zzzz = (GV *) (gv);                             \
           assert(isGV_with_GP(zzzz));                                  \
           assert(SvTYPE(zzzz) == SVt_PVGV || SvTYPE(zzzz) >= SVt_PVLV); \
+          assert(!SvVALID(zzzz));                                      \
           &(GvXPVGV(zzzz)->xiv_u.xivu_namehek);                        \
         }))
 #  define GvNAME_get(gv)       ({ assert(GvNAME_HEK(gv)); HEK_KEY(GvNAME_HEK(gv)); })
diff --git a/sv.h b/sv.h
index 5417759..9d8ef39 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -1056,6 +1056,20 @@ the scalar's value cannot change unless written to.
 #define SvEVALED_off(sv)       (SvFLAGS(sv) &= ~SVrepl_EVAL)
 
 #if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
+#  define SvVALID(sv)          ({ SV *const thwacke = (SV *) (sv);     \
+                                  if (SvFLAGS(thwacke) & SVpbm_VALID)  \
+                                      assert(!isGV_with_GP(thwacke));  \
+                                  (SvFLAGS(thwacke) & SVpbm_VALID);    \
+                               })
+#  define SvVALID_on(sv)       ({ SV *const thwacke = (SV *) (sv);     \
+                                  assert(!isGV_with_GP(thwacke));      \
+                                  (SvFLAGS(thwacke) |= SVpbm_VALID);   \
+                               })
+#  define SvVALID_off(sv)      ({ SV *const thwacke = (SV *) (sv);     \
+                                  assert(!isGV_with_GP(thwacke));      \
+                                  (SvFLAGS(thwacke) &= ~SVpbm_VALID);  \
+                               })
+
 #  define SvTAIL(sv)   ({ SV *const _svi = (SV *) (sv);                \
                            assert(SvTYPE(_svi) != SVt_PVAV);           \
                            assert(SvTYPE(_svi) != SVt_PVHV);           \
@@ -1063,6 +1077,9 @@ the scalar's value cannot change unless written to.
                                == (SVpbm_TAIL|SVpbm_VALID);            \
                        })
 #else
+#  define SvVALID(sv)          (SvFLAGS(sv) & SVpbm_VALID)
+#  define SvVALID_on(sv)       (SvFLAGS(sv) |= SVpbm_VALID)
+#  define SvVALID_off(sv)      (SvFLAGS(sv) &= ~SVpbm_VALID)
 #  define SvTAIL(sv)       ((SvFLAGS(sv) & (SVpbm_TAIL|SVpbm_VALID))   \
                             == (SVpbm_TAIL|SVpbm_VALID))
 
@@ -1070,9 +1087,6 @@ the scalar's value cannot change unless written to.
 #define SvTAIL_on(sv)          (SvFLAGS(sv) |= SVpbm_TAIL)
 #define SvTAIL_off(sv)         (SvFLAGS(sv) &= ~SVpbm_TAIL)
 
-#define SvVALID(sv)            (SvFLAGS(sv) & SVpbm_VALID)
-#define SvVALID_on(sv)         (SvFLAGS(sv) |= SVpbm_VALID)
-#define SvVALID_off(sv)                (SvFLAGS(sv) &= ~SVpbm_VALID)
 
 #ifdef USE_ITHREADS
 /* The following uses the FAKE flag to show that a regex pointer is infact