Browse thread
Unsafe features
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jacques Garrigue <garrigue@m...> |
| Subject: | Re: [Caml-list] Unsafe features |
From: Florian Weimer <fw@deneb.enyo.de> > I gave it a try and got: > > # let x : int = Obj.magic "x";; > val x : int = 67381588 > # x;; > - : int = 67381588 > # > > The "67381588" is just half the integral value of a heap address > (because of the tag bit, I presume). And looking at the ltrace > output, it seems that it is indeed close to the storage area of that > string. You are right indeed. Here is another way to see that this only changes the apparent type of the underlying value: # let x : int = Obj.magic (String.create 3);; val x : int = 67389852 # Gc.full_major();; - : unit = () # x;; - : int = 68129330 Oops, here is an integer that changes with the GC... Worse: # let y = x+13;; val y : int = 67407805 # Gc.full_major();; Segmentation fault Jacques