caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] What is an unsafe feature?
@ 2013-03-06 10:13 Hendrik Tews
  2013-03-06 10:36 ` David Allsopp
  0 siblings, 1 reply; 2+ messages in thread
From: Hendrik Tews @ 2013-03-06 10:13 UTC (permalink / raw)
  To: caml-list

Hi,

I always thought that the Obj module is unsafe and that functions
containing "unsafe" in their name are unsafe too. However, when I
run ocamlobjinfo on the .cmo of

    let f b =
      let a = "abcde" in
      let c = Obj.magic b in
      String.unsafe_blit c 0 a 0 5

I see (with 3.12.1 and 4.00.1)

    Uses unsafe features: no

So what is considered unsafe by ocamlobjinfo?

For .cmx files, ocamlobjinfo says nothing about unsafe features.
Is this info not present in the .cmx?

Bye,

Hendrik

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: [Caml-list] What is an unsafe feature?
  2013-03-06 10:13 [Caml-list] What is an unsafe feature? Hendrik Tews
@ 2013-03-06 10:36 ` David Allsopp
  0 siblings, 0 replies; 2+ messages in thread
From: David Allsopp @ 2013-03-06 10:36 UTC (permalink / raw)
  To: Hendrik Tews, caml-list

Hendrik Tews wrote:
> Hi,
> 
> I always thought that the Obj module is unsafe and that functions
> containing "unsafe" in their name are unsafe too. However, when I run
> ocamlobjinfo on the .cmo of
> 
>     let f b =
>       let a = "abcde" in
>       let c = Obj.magic b in
>       String.unsafe_blit c 0 a 0 5
> 
> I see (with 3.12.1 and 4.00.1)
> 
>     Uses unsafe features: no
> 
> So what is considered unsafe by ocamlobjinfo?

I think, looking at tools/objinfo.ml and tools/primreq.ml that this only refers to the compilation unit itself, not interfaces which it imports (try running ocamlobjinfo on stdlib.cma). The .cmo above simply imports Pervasives, String, Obj - the information that those are primitives is not recorded. If you changed it to:

external magic : 'a -> 'b = "%identity"
let f b =
  let a = "abcde" in
  let c = magic b in
  String.unsafe_blit c 0 a 0 5

Then you will see the unsafe features warning from ocamlobjinfo.


David

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-03-06 10:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-06 10:13 [Caml-list] What is an unsafe feature? Hendrik Tews
2013-03-06 10:36 ` David Allsopp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).