Skip to content

Commit d71d293

Browse files
committed
Les acces hors bornes dans les tableaux et les chaines levent tous la meme exception Invalid_arg("index out of bounds") pour compatibilite avec ocamlopt
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5950 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1 parent e492285 commit d71d293

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

byterun/array.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
CAMLprim value array_get_addr(value array, value index)
2727
{
2828
long idx = Long_val(index);
29-
if (idx < 0 || idx >= Wosize_val(array)) invalid_argument("Array.get");
29+
if (idx < 0 || idx >= Wosize_val(array)) array_bound_error();
3030
return Field(array, idx);
3131
}
3232

@@ -36,8 +36,8 @@ CAMLprim value array_get_float(value array, value index)
3636
double d;
3737
value res;
3838

39-
if (idx < 0 || idx >= Wosize_val(array) / Double_wosize)
40-
invalid_argument("Array.get");
39+
if (idx < 0 || idx >= Wosize_val(array) / Double_wosize)
40+
array_bound_error();
4141
d = Double_field(array, idx);
4242
#define Setup_for_gc
4343
#define Restore_after_gc
@@ -59,7 +59,7 @@ CAMLprim value array_get(value array, value index)
5959
CAMLprim value array_set_addr(value array, value index, value newval)
6060
{
6161
long idx = Long_val(index);
62-
if (idx < 0 || idx >= Wosize_val(array)) invalid_argument("Array.set");
62+
if (idx < 0 || idx >= Wosize_val(array)) array_bound_error();
6363
Modify(&Field(array, idx), newval);
6464
return Val_unit;
6565
}
@@ -68,7 +68,7 @@ CAMLprim value array_set_float(value array, value index, value newval)
6868
{
6969
long idx = Long_val(index);
7070
if (idx < 0 || idx >= Wosize_val(array) / Double_wosize)
71-
invalid_argument("Array.set");
71+
array_bound_error();
7272
Store_double_field(array, idx, Double_val(newval));
7373
return Val_unit;
7474
}

byterun/str.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ CAMLprim value create_string(value len)
5151
CAMLprim value string_get(value str, value index)
5252
{
5353
long idx = Long_val(index);
54-
if (idx < 0 || idx >= string_length(str)) invalid_argument("String.get");
54+
if (idx < 0 || idx >= string_length(str)) array_bound_error();
5555
return Val_int(Byte_u(str, idx));
5656
}
5757

5858
CAMLprim value string_set(value str, value index, value newval)
5959
{
6060
long idx = Long_val(index);
61-
if (idx < 0 || idx >= string_length(str)) invalid_argument("String.set");
61+
if (idx < 0 || idx >= string_length(str)) array_bound_error();
6262
Byte_u(str, idx) = Int_val(newval);
6363
return Val_unit;
6464
}

0 commit comments

Comments
 (0)