Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007683OCamlmiddle end (typedtree to clambda)public2017-11-29 16:132017-12-06 18:08
Reporterchambart 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusconfirmedResolutionopen 
PlatformOSOS Version
Product Version4.07.0+dev 
Target VersionFixed in Version 
Summary0007683: Mutable variables read shouldn't be substituted
DescriptionIn closure.ml the Uvar constructor is supposed to be pure by 'is_simple_argument', but when the variable is mutable this
can be wrong.
Steps To ReproduceThis program exhibit the problem, it returns 1 in bytecode and flambda and 2 with closure.

let f () n () =
  n

let g () =
  let r = ref 0 in
  f (incr r) !r (incr r)

let () = print_int (g ())
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0018722)
nojebar (developer)
2017-11-29 22:34

https://github.com/ocaml/ocaml/pull/1499 [^]
(0018723)
gasche (developer)
2017-11-30 00:03

Given that the order of evaluation of arguments is unspecified, I have the impression that both reported behaviors (printing 1 or 2) are correct with respect to the language specification. Do you have an example where the observed behavior is actually a bug?
(0018724)
nojebar (developer)
2017-11-30 00:24

Even if evaluation order is unspecified, do we really want to have different behavior in bytecode and native-code?

Not that long ago at least two PRs were merged precisely to uniformise argument evaluation between bytecode and native-code: https://github.com/ocaml/ocaml/pull/966 [^] and https://github.com/ocaml/ocaml/pull/967. [^]
(0018725)
gasche (developer)
2017-11-30 06:37

Are you replying this because there is no example that is actually a bug (I would find it surprising, and an interesting information), or because you would rather avoid doing the work of thinking of an example that is actually a bug?
(0018726)
nojebar (developer)
2017-11-30 09:19

I tried to find an example that is a bug but so far without success.
(0018736)
shinwell (developer)
2017-12-06 18:08

I have posted an example of a bug which I think is due to this issue on GPR#1499.

- Issue History
Date Modified Username Field Change
2017-11-29 16:13 chambart New Issue
2017-11-29 18:35 chambart Category back end (clambda to assembly) => middle end (typedtree to clambda)
2017-11-29 22:34 nojebar Note Added: 0018722
2017-11-30 00:03 gasche Note Added: 0018723
2017-11-30 00:24 nojebar Note Added: 0018724
2017-11-30 06:37 gasche Note Added: 0018725
2017-11-30 09:19 nojebar Note Added: 0018726
2017-12-06 18:08 shinwell Note Added: 0018736
2017-12-06 18:08 shinwell Status new => confirmed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker