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
match branches wrongly merged #6322
Comments
Comment author: @alainfrisch Is this really a bug? The "sharing" semantics of string literals is not really specified. The manual says (http://caml.inria.fr/pub/docs/manual-ocaml/libref/String.html): [...] both the OCaml compiler and most OCaml libraries share strings as if they were immutable, rather than copying them. |
Comment author: @chambart I am not sure of which semantics we really want, but I consider that adding '();' shouldn't change the semantics |
Comment author: @garrigue If the semantics is undefined, anything can change the result... |
Comment author: @alainfrisch For OS which support read-only pages, I'm wondering if it would be feasible to make string literals read-only. Any attempt to modify them would trigger a trap (which one could hopefully turn into an OCaml exception). |
Comment author: @mshinwell Making them read-only seems like a potentially good idea. |
Comment author: @maranget I would tend to correct this misbehaviour, as it is rather surprising. |
Comment author: @maranget The misbehaviour is now fixed in trunk. --Luc |
Original bug ID: 6322
Reporter: @chambart
Assigned to: @maranget
Status: closed (set by @xavierleroy on 2015-12-11T18:25:41Z)
Resolution: fixed
Priority: normal
Severity: minor
Category: back end (clambda to assembly)
Tags: patch
Monitored by: @gasche @jmeber @hcarty
Bug description
This code fails:
let g x = match x with (* branch are merged *)
| true -> "a"
| false -> "a"
let f x = match x with (* branch are not merged *)
| true -> (); "a"
| false -> "a"
let () =
let s1 = f true in
let s2 = f false in
let s3 = g true in
let s4 = g false in
s1.[0] <- 'p';
s3.[0] <- 'p';
assert(s2 = s4) (* s2 is "p" and s4 is still "a" *)
This is due to Lambda.same considering constant strings as equal terms.
File attachments
The text was updated successfully, but these errors were encountered: