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: Wed, 3 Oct 2007 08:10:17 +0300
User-agent: Mutt/1.5.16 (2007-06-11)

On Tue, Oct 02, 2007 at 06:26:58PM -0500, Rob Landley wrote:
> Confirmed that gcc makes sizeof() a runtime function in this case:
> 
> #include <stdio.h>
> 
> int main(int argc, char *argv[])
> {
>   int walrus[atoi(argv[1])];
>   printf("%d\n", sizeof(walrus));
>   return 0;
> }
> 
> Running "./a.out 42" produced 168.
> 
> Oh yeah, that's gonna be fun...

As far as I can tell, it's supposed to be implemented as the equivalent of:

  size_t walrus_sizeof = atoi(argv[1]);
  int walrus[walrus_sizeof];
  printf("%d\n", walrus_sizeof);
  return 0;

Obviously, walrus_sizeof should not actually be named in such a way but
to be a fresh compiler-generated name.

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