Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007346OCamlmiddle end (typedtree to clambda)public2016-09-08 15:572017-03-06 16:21
Reporterdoligez 
Assigned Toshinwell 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionduplicate 
PlatformOSOS Version
Product Version4.04.0 +dev / +beta1 / +beta2 
Target Version4.05.0 +dev/beta1/beta2/beta3/rc1Fixed in Version 
Summary0007346: order of evaluation vs the ! operator
DescriptionWith 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 ReproduceTry this with ocamlc and ocamlopt:
----
let get r = !r [@@inline never]

let i = ref 0
let incr_i () = incr i; !i

let f (x, y) = Printf.printf "%d %d\n" x y [@@inline never]
let _ = f (incr_i (), get i)

let g x y = 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.
TagsNo tags attached.
Attached Files

- Relationships
related to 0004072resolvedlefessan Ordre d'√©valuation inattendu 
related to 0006136closed Function call evaluation order varies more than manual allows 

-  Notes
(0016991)
shinwell (developer)
2016-12-13 11:22

Superceded by https://github.com/ocaml/ocaml/pull/966 [^]

- Issue History
Date Modified Username Field Change
2016-09-08 15:57 doligez New Issue
2016-09-08 15:58 doligez Relationship added related to 0004072
2016-09-08 15:58 doligez Relationship added related to 0006136
2016-09-08 15:58 doligez Steps to Reproduce Updated View Revisions
2016-09-27 14:03 doligez Status new => confirmed
2016-09-27 14:03 doligez Target Version => 4.05.0 +dev/beta1/beta2/beta3/rc1
2016-12-08 15:54 shinwell Category OCaml backend (code generation) => Ocaml optimization
2016-12-13 11:22 shinwell Note Added: 0016991
2016-12-13 11:22 shinwell Status confirmed => closed
2016-12-13 11:22 shinwell Assigned To => shinwell
2016-12-13 11:22 shinwell Resolution open => duplicate
2017-02-23 16:42 doligez Category Ocaml optimization => -Ocaml optimization
2017-03-06 16:21 doligez Category -Ocaml optimization => middle end (typedtree to clambda)


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker