summaryrefslogtreecommitdiff
path: root/testsuite/tests/backtrace/backtrace_bounds_exn.ml
blob: 1c08933f96479fd331a73e3949210bd85914b899 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(* TEST_BELOW
(* Blank lines added here to preserve locations. *)

*)

(* #11436: bad backtrace for out-of-bounds exception *)

let xs = [| 0; 1; 2 |]

let [@inline never] bad_bound_fn x =
  !x + xs.(100)

let _ =
  try
    ignore (Sys.opaque_identity (bad_bound_fn (ref 0)));
  with exn ->
    Printf.printf "Uncaught exception %s\n" (Printexc.to_string exn);
    Printexc.print_backtrace stdout;

  print_endline "OK"

(* TEST
 flags = "-g";
 ocamlrunparam += ",b=1";
*)