From: Kim Nguyễn Date: Sat, 13 Oct 2012 12:54:02 +0000 (+0200) Subject: Add runtime assertion to check that values passed to Obj_val() X-Git-Url: http://git.nguyen.vg/gitweb/?p=SXSI%2Fxpathcomp.git;a=commitdiff_plain;h=eb9a6467cb0860abf57f773a82da526aedc9802a Add runtime assertion to check that values passed to Obj_val() are indeed custom blocks. --- diff --git a/myocamlbuild.ml b/myocamlbuild.ml index 7a792d1..6f27e4e 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -127,7 +127,7 @@ let () = dispatch begin compile_flags @= [A "-noassert"]; pp_macro_options @= [ A "-unsafe" ]; native_compile_flags @= [ A "-inline"; A ocaml_inline ]; - cxx_flags @= [ A "-O3" ] + cxx_flags @= [ A "-O3"; A "-DNDEBUG" ] end; let dir_path = Pathname.pwd / src_path in diff --git a/src/common_stub.hpp b/src/common_stub.hpp index 3e874b7..45aa0ca 100644 --- a/src/common_stub.hpp +++ b/src/common_stub.hpp @@ -14,6 +14,7 @@ extern "C" { } #include #include +#include #define NoAlloc @@ -26,6 +27,7 @@ value alloc_custom_(char* name); template X& Obj_val(value v) { + assert(Tag_val(v) == Custom_tag); return * (X*) Data_custom_val(v); }