New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'index out of bound' check too early? #4892
Comments
Comment author: ertai Why do you expects the arguments of this function to be all evaluated before doing the update. Array.set could morally be seen as: let set array index = Which have the nice property of checking once the bounds: let isetter = Array.set array i in However the reports is still worthy since the behavior should be the same in bytecode. |
Comment author: @alainfrisch
Because, in a call-by-value language, as I said, one expects arguments of a function call to be evaluated before the function is called. |
Comment author: @damiendoligez This bug seems to be a kind of dual to #2719... |
Comment author: @alainfrisch The bug is in Cmmgen.transl_prim_3 and the fix is straightforward (always bind "newval" to arg3). |
Comment author: @xavierleroy Fixed in 4.00 release branch (r12237) and in trunk (r12238). |
Original bug ID: 4892
Reporter: @alainfrisch
Status: closed (set by @xavierleroy on 2013-08-31T10:48:44Z)
Resolution: fixed
Priority: low
Severity: minor
Fixed in version: 4.00.0+dev
Category: ~DO NOT USE (was: OCaml general)
Related to: #2719
Monitored by: @ygrek
Bug description
One expects arguments of a function call to be evaluated before the function is called. This is not the case in the following expression, using the native code compiler:
let () = Array.set [| |] 0 (print_endline "XXX")
The exception Invalid_argument("index out of bounds") is raised before the argument (print_endline "XXX") is evaluated.
The text was updated successfully, but these errors were encountered: