Index: src/examples/gc_no_raii/src/gcpointers.c
===================================================================
--- src/examples/gc_no_raii/src/gcpointers.c	(revision 76af36f4a9e47a83d4e2a30ce79b4fda2dd395e7)
+++ src/examples/gc_no_raii/src/gcpointers.c	(revision 4c1403cc8cf803411997296a4715a0153ca7ef92)
@@ -80,18 +80,36 @@
 
 //Logical operators
-bool gcpointer_equal(gcpointer_t* this, gcpointer_t* rhs)
+bool gcpointer_equal(const gcpointer_t* this, const gcpointer_t* rhs)
 {
 	return this->ptr == rhs->ptr;
 }
 
-bool gcpointer_not_equal(gcpointer_t* this, gcpointer_t* rhs)
+bool gcpointer_not_equal(const gcpointer_t* this, const gcpointer_t* rhs)
 {
 	return this->ptr != rhs->ptr;
 }
 
-bool gcpointer_null(gcpointer_t* this)
+bool gcpointer_null(const gcpointer_t* this)
 {
 	return this->ptr == (intptr_t)NULL;
 }
+
+#ifndef NDEBUG
+	bool is_valid(const gcpointer_t* this) {
+		if(gcpointer_null(this)) return true;
+
+		gc_object_header* obj = gc_get_object_ptr((void*)this->ptr);
+		check(obj);
+		check(is_valid(obj));
+		check(!obj->root_chain || this->ptr == obj->root_chain->ptr);
+
+		if( !gc_is_managed(this))
+		{
+			check( !(this->next) || this->ptr == this->next->ptr );
+		}
+
+		return true;
+	}
+#endif
 
 forall(otype T) void ?{}(gcpointer(T)* this) {
Index: src/examples/gc_no_raii/src/gcpointers.h
===================================================================
--- src/examples/gc_no_raii/src/gcpointers.h	(revision 76af36f4a9e47a83d4e2a30ce79b4fda2dd395e7)
+++ src/examples/gc_no_raii/src/gcpointers.h	(revision 4c1403cc8cf803411997296a4715a0153ca7ef92)
@@ -22,5 +22,10 @@
 bool gcpointer_equal(gcpointer_t* this, gcpointer_t* rhs);
 bool gcpointer_not_equal(gcpointer_t* this, gcpointer_t* rhs);
-bool gcpointer_null(gcpointer_t* this);
+bool gcpointer_null(const gcpointer_t* this);
+
+
+#ifndef NDEBUG
+	bool is_valid(const gcpointer_t* this);
+#endif
 
 forall(dtype T)
Index: src/examples/gc_no_raii/test/badlll.c
===================================================================
--- src/examples/gc_no_raii/test/badlll.c	(revision 76af36f4a9e47a83d4e2a30ce79b4fda2dd395e7)
+++ src/examples/gc_no_raii/test/badlll.c	(revision 4c1403cc8cf803411997296a4715a0153ca7ef92)
@@ -35,4 +35,6 @@
 	}
 
+	check(is_valid( &ll0.internal ));
+
 	return ll0;
 }
