This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
assert that SvTAIL() isn't being called on PVAVs or PVHVs
authorNicholas Clark <nick@ccl4.org>
Fri, 8 Dec 2006 23:22:31 +0000 (23:22 +0000)
committerNicholas Clark <nick@ccl4.org>
Fri, 8 Dec 2006 23:22:31 +0000 (23:22 +0000)
p4raw-id: //depot/perl@29491

sv.h

diff --git a/sv.h b/sv.h
index 4ec96e8..054ec6b 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -349,7 +349,7 @@ perform the upgrade if necessary.  See C<svtype>.
 #define SVpav_REAL     0x40000000      /* free old entries */
 /* PVHV */
 #define SVphv_LAZYDEL  0x40000000      /* entry in xhv_eiter must be deleted */
-/* PVBM */
+/* Not just PVBM - basically anything that can be a regular scalar */
 #define SVpbm_TAIL     0x40000000
 /* ??? */
 #define SVrepl_EVAL    0x40000000      /* Replacement part of s///e */
@@ -1059,7 +1059,15 @@ the scalar's value cannot change unless written to.
 #define SvEVALED_on(sv)                (SvFLAGS(sv) |= SVrepl_EVAL)
 #define SvEVALED_off(sv)       (SvFLAGS(sv) &= ~SVrepl_EVAL)
 
-#define SvTAIL(sv)             (SvFLAGS(sv) & SVpbm_TAIL)
+#if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
+#  define SvTAIL(sv)   ({ SV *const _svi = (SV *) (sv);                \
+                           assert(SvTYPE(_svi) != SVt_PVAV);           \
+                           assert(SvTYPE(_svi) != SVt_PVHV);           \
+                           SvFLAGS(sv) & SVpbm_TAIL;                   \
+                       })
+#else
+#  define SvTAIL(sv)           (SvFLAGS(sv) & SVpbm_TAIL)
+#endif
 #define SvTAIL_on(sv)          (SvFLAGS(sv) |= SVpbm_TAIL)
 #define SvTAIL_off(sv)         (SvFLAGS(sv) &= ~SVpbm_TAIL)