From: "Li-Thiao-Té Sébastien" <sayan@crans.org>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Allocating caml lists from C : possible bug on amd64
Date: Mon, 13 Mar 2006 19:05:16 +0100 [thread overview]
Message-ID: <4415B45C.5040302@crans.org> (raw)
In-Reply-To: <4415AF18.5070404@inria.fr>
Xavier Leroy wrote:
>>I have already tried to be GC-friendly, and use the "standard" way to do
>>things. For example the following function also works using a 32-bit
>>chroot, but also fails with the 64-bit compiler. The question is : why
>>does it fail with the 64-bit compiler?
>
> Because your C code is wrong. gcc -Wall is your friend.
>
>>#include <stdio.h>
>>#include <caml/mlvalues.h>
>>#include <caml/memory.h>
>>#include <caml/bigarray.h>
>>
>>test_liste (value str) {
>
> Should be "value test_list(value str)".
>
Indeed, but my previous mail to this list read "value test_liste (value
str)". No problem noticed without it.
>> // test function to return a list to caml
>>// value cons;
>>// cons = caml_alloc_small (2,0);
>>// caml_modify(&Field(cons,0),Val_int(0));
>>// caml_modify(&Field(cons,1),Val_int(0));
>>
>> CAMLparam1(str);
>> CAMLlocal1(cons);
>> cons = caml_alloc (2,0);
>
> You haven't declared caml_alloc (include <caml/alloc.h>), so the C
> compiler assumes it returns an int instead of a value, and generates
> wrong code.
>
That was the main problem.
>> Store_field(cons,0, Val_int(1));
>> Store_field(cons,1, Val_int(0));
>>
>> printf("This is test_liste.\n");
>> printf(String_val(str));
>
> Should be: printf("%s", String_val(str));
>
> (Hint: what happens if str contains "%s" ?)
>
Well, that one was rather a non-production-ready test anyway. I was
blocked before even reaching that point.
Thanks very much for the help and the -Wall flag. I should have known :)
--
Li-Thiao-Té Sébastien
next prev parent reply other threads:[~2006-03-13 18:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-08 22:06 Caml interface with C on x86_64 Li-Thiao-Té Sébastien
2006-03-13 14:53 ` Allocating caml lists from C : possible bug on amd64 "Sayan (Sébastien Li-Thiao-Té)"
2006-03-13 15:13 ` [Caml-list] " Markus Mottl
2006-03-13 15:54 ` "Sayan (Sébastien Li-Thiao-Té)"
2006-03-13 16:39 ` Markus Mottl
2006-03-13 17:42 ` Xavier Leroy
2006-03-13 18:05 ` Li-Thiao-Té Sébastien [this message]
2006-03-13 18:53 ` Markus Mottl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4415B45C.5040302@crans.org \
--to=sayan@crans.org \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).