tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Buiding binutils 2.17 (needs dynamic arrays).


From: Antti-Juhani Kaijanaho
Subject: Re: [Tinycc-devel] Buiding binutils 2.17 (needs dynamic arrays).
Date: Thu, 4 Oct 2007 06:30:12 +0300
User-agent: Mutt/1.5.16 (2007-06-11)

On Wed, Oct 03, 2007 at 05:17:23PM -0500, Rob Landley wrote:
> If you jump inside its scope you must initialize it (call alloca).

I'm a little worried about the "use alloca" thing you have here (in
general, not just this particular quote).  alloca has all sorts of nasty 
problems, which is a reason why it's not in the standard and VLAs are.
Of course, it's just a worry, I don't have a specific objection.

Just allocate the array from the stack.  Decreasing ESP by the size and
then using the resulting ESP as the array start pointer ought to work,
as far as I can see.  Not having looked at the tcc code I'd assume
that's what tcc does when allocating auto variables in any case.

> Soundsw like you can't jump over the initialization.

Yes, I believe that's the intent.

BTW, are you aware of the C99 rationale document?  It explains why
some stuff is in the standard and why some other stuff is not, and why
the stuff that is in there is the way it is.

http://www.open-std.org/jtc1/sc22/wg14/www/C99RationaleV5.10.pdf

> > int foo(size_t n, int arr[n++])
> > {
> >     ...
> > }
> 
> In the absence of code I care about actually doing this, I'm not even going 
> to 
> try to support that.  Just use int *arr and copy the darn thing with alloca() 
> if you need to.  This is getting _way_ too fancy at the language level...

alloca is not portable, VLAs (theoretically) are.  But I agree, not
supporting everything is not a problem, as long as the compiler doesn't
assign non-standard semantics for the stuff.

> kraah+1 resolves to a pointer, that should be what gets passed on the stack, 

That *is* what gets passed.  The VLA degenerates to a pointer like any
other array parameter.

> and if the function wants to copy if the function can copy it.

Yes.

> Darn silly to try to make the language do this.  This is C, not python...

I believe the appropriate comparison in this case is "This is C, not
Fortran".  VLAs (like _Complex) has a significant (potential) user base
in the scientific computing community.

-- 
Antti-Juhani Kaijanaho, Jyväskylä, Finland
http://antti-juhani.kaijanaho.fi/newblog/
http://www.flickr.com/photos/antti-juhani/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]