summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2001-08-08 08:30:26 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2001-08-08 08:30:26 +0000
commitbf110cd0e2d7a3b8fa4ccc4c9def548e86a2afdb (patch)
treeeaeeac0a79c1e30ca394086110a4cb7932ac3a2c /test
parentfbe4ff190f54f2ba158f8c8404629d49076144d6 (diff)
downloadocaml-bf110cd0e2d7a3b8fa4ccc4c9def548e86a2afdb.tar.gz
Detection du debordement de pile C
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3621 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'test')
-rw-r--r--test/Moretest/stackoverflow.ml15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/Moretest/stackoverflow.ml b/test/Moretest/stackoverflow.ml
new file mode 100644
index 0000000000..4d211bc828
--- /dev/null
+++ b/test/Moretest/stackoverflow.ml
@@ -0,0 +1,15 @@
+let rec f x =
+ if x land 0xFFFF <> 0
+ then 1 + f (x + 1)
+ else
+ try
+ 1 + f (x + 1)
+ with Stack_overflow ->
+ print_string "x = "; print_int x; print_newline();
+ raise Stack_overflow
+
+let _ =
+ try
+ ignore(f 0)
+ with Stack_overflow ->
+ print_string "Stack overflow caught"; print_newline()