Re: [C--] Segmentation fault (cannot take the address of a formal parameter)
Ning Wang <[email protected]> Fri, 27 Mar 2009 05:31:38 -0700
| Newsgroups | gmane.comp.lang.c-- |
|---|---|
| Message-ID | <[email protected]> |
John Dias wrote:
>> This is bad. Anyway, the c-- code seems correct, but the executable code
>
> The call to strcmp passes the wrong value for the first argument:
>
> _fooret = foreign "C" strcmp (bits32[a_T_155],
> str__a_da_289565476_1);
>
> The first argument here is not the address of the string: it is the
> result of loading 32 bits from the address of the string. You want:
>
> _fooret = foreign "C" strcmp (a_T_155, str__a_da_289565476_1);
>
> Cheers,
> -j
The formal parameters of a C-- procedure are always passed in
registers. This suggests that there is no corresponding C--
representation for the following C code:
int foo (int argc)
{
int * ptr = & argc;
printf ("%p\n", ptr);
}
I believe it's a known issue to C-- folks, since the manual mentions no
support for "varargs". But it's still a little surprise.
Thanks,
Ning
_______________________________________________
Cminusminus mailing list
[email protected]
https://www.eecs.harvard.edu/mailman/listinfo/cminusminus