You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 6575 Reporter: gerd Assigned to:@alainfrisch Status: closed (set by @xavierleroy on 2017-02-16T14:18:27Z) Resolution: fixed Priority: normal Severity: minor Version: 4.02.0 Target version: 4.02.2+dev / +rc1 Category: standard library Related to:#4950 Monitored by:@hcarty
Bug description
Look at this (ocaml-4.02):
let n = 0 ;;
ignore (Array.init (n-1) (fun _ -> assert false));;
This is straight-forward from the definition of Array.init, but nevertheless quite surprising behavior, because all other stdlib functions check the arguments before calling anything back.
The text was updated successfully, but these errors were encountered:
Commit 15898 on 4.02, 15899 on trunk. I've added a check for size < 0 before calling Array.make. Notes:
Array.init used to raise (Invalid_argument "Array.make") in that case, not it raises (Invalid_argument "Array.init"). I don't expect this to break any code and is clearly better.
Checking for the maximum array size is more difficult, since this size depends on whether we are building an array of floats or a regular array (and we don't know before calling the initializer once). Anyway, it is less clear that when the size is too large, the callback should not be called at all.
Original bug ID: 6575
Reporter: gerd
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2017-02-16T14:18:27Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.0
Target version: 4.02.2+dev / +rc1
Category: standard library
Related to: #4950
Monitored by: @hcarty
Bug description
Look at this (ocaml-4.02):
let n = 0 ;;
ignore (Array.init (n-1) (fun _ -> assert false));;
$ ocamlopt -o m m.ml
$ ./m
Fatal error: exception Assert_failure("m.ml", 2, 35)
Same with ocamlc.
Additional information
This is straight-forward from the definition of Array.init, but nevertheless quite surprising behavior, because all other stdlib functions check the arguments before calling anything back.
The text was updated successfully, but these errors were encountered: