Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004892OCamlOCaml generalpublic2009-10-15 00:352013-08-31 12:48
Reporterfrisch 
Assigned To 
PrioritylowSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version4.00.0+dev 
Summary0004892: 'index out of bound' check too early?
DescriptionOne 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.
TagsNo tags attached.
Attached Files

- Relationships
related to 0002719acknowledged Proble in the Mac OS X compiler [PPC code generator] 

-  Notes
(0005131)
ertai (developer)
2009-10-15 15:12

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 =
   ...bound...check... array index;
   fun v -> ...update...code...

Which have the nice property of checking once the bounds:

let isetter = Array.set array i in
let rec ... k = ... isetter k ...

However the reports is still worthy since the behavior should be the same in bytecode.
(0005132)
frisch (developer)
2009-10-15 16:27

>Why do you expects the arguments of this function to be all evaluated before
>doing the update.

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.
(0005133)
doligez (administrator)
2009-10-15 17:39

This bug seems to be a kind of dual to PR#2719...
(0005140)
frisch (developer)
2009-10-20 12:57

The bug is in Cmmgen.transl_prim_3 and the fix is straightforward (always bind "newval" to arg3).
(0007070)
xleroy (administrator)
2012-03-14 10:27

Fixed in 4.00 release branch (r12237) and in trunk (r12238).

- Issue History
Date Modified Username Field Change
2009-10-15 00:35 frisch New Issue
2009-10-15 15:12 ertai Note Added: 0005131
2009-10-15 16:27 frisch Note Added: 0005132
2009-10-15 17:38 doligez Relationship added related to 0002719
2009-10-15 17:39 doligez Note Added: 0005133
2009-10-15 17:39 doligez Reproducibility have not tried => always
2009-10-15 17:39 doligez Status new => acknowledged
2009-10-20 12:57 frisch Note Added: 0005140
2012-02-14 15:26 gasche Status acknowledged => confirmed
2012-03-14 10:27 xleroy Note Added: 0007070
2012-03-14 10:27 xleroy Status confirmed => resolved
2012-03-14 10:27 xleroy Resolution open => fixed
2012-03-14 10:27 xleroy Fixed in Version => 4.00.0+dev
2013-08-31 12:48 xleroy Status resolved => closed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker