Skip to content
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

Mutable variables read shouldn't be substituted #7683

Closed
vicuna opened this issue Nov 29, 2017 · 6 comments · Fixed by #1499
Closed

Mutable variables read shouldn't be substituted #7683

vicuna opened this issue Nov 29, 2017 · 6 comments · Fixed by #1499

Comments

@vicuna
Copy link

vicuna commented Nov 29, 2017

Original bug ID: 7683
Reporter: @chambart
Status: confirmed (set by @mshinwell on 2017-12-06T17:08:41Z)
Resolution: open
Priority: normal
Severity: minor
Version: 4.07.0+dev/beta2/rc1/rc2
Category: middle end (typedtree to clambda)
Monitored by: @nojb @gasche @alainfrisch

Bug description

In 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 reproduce

This 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 ())

@vicuna
Copy link
Author

vicuna commented Nov 29, 2017

Comment author: @nojb

#1499

@vicuna
Copy link
Author

vicuna commented Nov 29, 2017

Comment author: @gasche

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?

@vicuna
Copy link
Author

vicuna commented Nov 29, 2017

Comment author: @nojb

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: #966 and #967.

@vicuna
Copy link
Author

vicuna commented Nov 30, 2017

Comment author: @gasche

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?

@vicuna
Copy link
Author

vicuna commented Nov 30, 2017

Comment author: @nojb

I tried to find an example that is a bug but so far without success.

@vicuna
Copy link
Author

vicuna commented Dec 6, 2017

Comment author: @mshinwell

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant