Re: [C--] Segmentation fault (cannot take the address of a formal parameter)

[email protected] Fri, 27 Mar 2009 08:39:25 -0400
Newsgroups gmane.comp.lang.c--
Message-ID <[email protected]>
On Fri, Mar 27, 2009 at 05:31:38AM -0700, Ning Wang wrote:
> 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.  

Always?  Is there a limit on the mumber of parameters?

> 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.

Which brings up an interesting question -- how does the C front end 
translate varargs into C--?

-- hendrik
_______________________________________________
Cminusminus mailing list
[email protected]
https://www.eecs.harvard.edu/mailman/listinfo/cminusminus