caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] external function with arity > 5 and "noalloc"
@ 2013-08-21 16:37 Florent Monnier
  2013-08-22  8:44 ` David Allsopp
  0 siblings, 1 reply; 2+ messages in thread
From: Florent Monnier @ 2013-08-21 16:37 UTC (permalink / raw)
  To: caml-list

Hi,

I'm not sure if this behavior is a bug or not.
Here a given function defined in a stub:

cat > bind.ml <<EOF
external f :
  v1:int ->
  v2:int ->
  v3:int ->
  v4:int ->
  v5:int ->
  v6:int -> int
  = "bind_f"
    "bind_f_bc"
    "noalloc"
EOF

if compiles fine with all warnings on:
ocamlopt -c -w +A -warn-error +A bind.ml

if will also compile fine with:
  = "bind_f"
    "bind_f_bc"

if I put only:
  = "bind_f"

I get a compilation error, which is what I expected:

ocamlopt -c -w +A -warn-error +A bind.ml

File "bind.ml", line 2, characters 2-75:
Error: An external function with more than 5 arguments requires
  a second stub function for native-code compilation


But now if I write this way:
  = "bind_f"
    "noalloc"
then I get no compile error anymore.

I may be wrong again, but I guess this is not the expected behavior.

In case this is indeed a bug, maybe I've been through mantis list
without seeing it, but it seems not to be registered yet.

-- 
Regards

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

* RE: [Caml-list] external function with arity > 5 and "noalloc"
  2013-08-21 16:37 [Caml-list] external function with arity > 5 and "noalloc" Florent Monnier
@ 2013-08-22  8:44 ` David Allsopp
  0 siblings, 0 replies; 2+ messages in thread
From: David Allsopp @ 2013-08-22  8:44 UTC (permalink / raw)
  To: caml-list

Florent Monnier wrote:
> Hi,
> 
> I'm not sure if this behavior is a bug or not.
> Here a given function defined in a stub:
> 
> cat > bind.ml <<EOF
> external f :
>   v1:int ->
>   v2:int ->
>   v3:int ->
>   v4:int ->
>   v5:int ->
>   v6:int -> int
>   = "bind_f"
>     "bind_f_bc"
>     "noalloc"
> EOF

The naming you're using here implies you've got these the wrong way around - the bytecode stub comes first (I'm assuming that's what _bc means) - see 19.1.2 in the manual.

> if compiles fine with all warnings on:
> ocamlopt -c -w +A -warn-error +A bind.ml
> 
> if will also compile fine with:
>   = "bind_f"
>     "bind_f_bc"
> 
> if I put only:
>   = "bind_f"
> 
> I get a compilation error, which is what I expected:
> 
> ocamlopt -c -w +A -warn-error +A bind.ml
> 
> File "bind.ml", line 2, characters 2-75:
> Error: An external function with more than 5 arguments requires
>   a second stub function for native-code compilation
> 
> 
> But now if I write this way:
>   = "bind_f"
>     "noalloc"
> then I get no compile error anymore.

This isn't a bug - are you able to link the executable? What you've specified is an external f using a function bind_f for bytecode and noalloc for native code - unless there is a symbol noalloc knocking around somewhere in the runtime, I'd expect you to get a linking error with ocamlopt and either a linking error or a runtime segfault with ocamlc (because of using bind_f not bind_f_bc).

"noalloc" as a string rather than a keyword is a bit of a hack (though I'm sure there's a logical reason it was done that way - although it does just look a teensy bit lazy as it means the grammar for external is simply a string list!). What is a bug is that noalloc isn't mentioned in Chapter 19 of the manual (similarly for "float" which can also be specified).


David 


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

end of thread, other threads:[~2013-08-22  8:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-21 16:37 [Caml-list] external function with arity > 5 and "noalloc" Florent Monnier
2013-08-22  8:44 ` 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).