This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add some paranoia to check that GP accesses aren't being done on the
[perl5.git] / gv.h
diff --git a/gv.h b/gv.h
index d9a5b51..f179494 100644 (file)
--- a/gv.h
+++ b/gv.h
@@ -24,7 +24,14 @@ struct gp {
 
 #define GvXPVGV(gv)    ((XPVGV*)SvANY(gv))
 
-#define GvGP(gv)       (GvXPVGV(gv)->xgv_gp)
+#ifdef DEBUGGING
+#  define GvGP(gv)     (*(assert(SvTYPE(gv) == SVt_PVGV || \
+                                 SvTYPE(gv) == SVt_PVLV), \
+                          &(GvXPVGV(gv)->xgv_gp)))
+#else
+#  define GvGP(gv)     (GvXPVGV(gv)->xgv_gp)
+#endif
+
 #define GvNAME(gv)     (GvXPVGV(gv)->xgv_name)
 #define GvNAMELEN(gv)  (GvXPVGV(gv)->xgv_namelen)
 #define GvSTASH(gv)    (GvXPVGV(gv)->xgv_stash)