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

local string variables and String.set #2579

Closed
vicuna opened this issue Oct 3, 2000 · 1 comment
Closed

local string variables and String.set #2579

vicuna opened this issue Oct 3, 2000 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Oct 3, 2000

Original bug ID: 197
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Claude Marche
Version: 3.00
OS: Linux
Submission from: pc801.lri.fr (129.175.8.109)

C'est clairement mis en evidence par le test ci-dessous. Le bug a lieu avec
ocamlc pas ocamlopt

pc801:~> cat bug.ml

let f () =
let s = "+" in
Format.print_string (if s = "+" then "ok\n" else "bug\n");
String.set s 0 '-'
;;
f ();;
f ();;
pc801:> ocamlc -o bug bug.ml
pc801:
> ./bug
ok
bug
pc801:> ocamlopt -o bug bug.ml
pc801:
> ./bug
ok
ok
pc801:~>

@vicuna
Copy link
Author

vicuna commented Apr 2, 2001

Comment author: administrator

Literal strings are mutable in OCaml and we can't reasonably change this
behavior. For ocamlopt, the test "works" because the two "+" literal strings
are re-shared by the code generator! This questionable behavior removed
2001-04-02 by XL because it caused other problems.

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

No branches or pull requests

1 participant