From eb9a6467cb0860abf57f773a82da526aedc9802a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kim=20Nguy=E1=BB=85n?= Date: Sat, 13 Oct 2012 14:54:02 +0200 Subject: [PATCH] Add runtime assertion to check that values passed to Obj_val() are indeed custom blocks. --- myocamlbuild.ml | 2 +- src/common_stub.hpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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); } -- 2.17.1