Original bug ID: 7346 Reporter:@damiendoligez Assigned to:@mshinwell Status: closed (set by @mshinwell on 2016-12-13T10:22:18Z) Resolution: duplicate Priority: normal Severity: major Version: 4.04.0 +dev / +beta1 / +beta2 Target version: 4.05.0 +dev/beta1/beta2/beta3/rc1 Category: middle end (typedtree to clambda) Related to:#4072#6136 Monitored by:@gasche@yallop@hcarty
With ocamlopt, the order of evaluation of function arguments depends on the code generated for the argument after inlining.
With ocamlc and ocamlopt+flambda, the order is always the same.
Steps to reproduce
Try this with ocamlc and ocamlopt:
letgetr=!r [@@inline never]
let i =ref0letincr_i()= incr i; !i
letf (x, y) =Printf.printf "%d %d\n" x y [@@inline never]
let _ = f (incr_i (), get i)
letgxy=Printf.printf "%d %d\n" x y [@@inline never]
let()= g (incr_i ()) (get i)
They give the same result, all is well.
Remove the [@@inline never] annotation on the first line and they give different results.
Now make the function more complex (let get r = !r + (let rec f x = if x < 1 then 0 else 1 + f (x-1) in f 0)) and the result changes again.
The text was updated successfully, but these errors were encountered: