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

Re: gcc memory allocation



Constantin Eizner <eizner@research.haifa.ac.il> writes:

> 
> I was really sure that it doesn't work.
> I expected for message like " constant expected" or something like that.
> 
> Nothing was happened.
> How the hell that work. What about memory allocation theory.
> Or I'm crazy.
> 
> irina [10] /tmp > gcc test.c
> irina [11] /tmp >
> 
> void main()
> {
> int n=9;
> int a[n];
> }
> 

I didn't learn 'Theory of Compilation'. :-) However I'm pretty
confident that:

1. Constructs like int foo...; ...bar[foo] are allowed as GCC
   extensions.

2. Certain flags (-ansi -Wall) make gcc complain about them.

3. In the program above, n's value is not known 'at compile time'
   according to ANSI C. It may be known to an optimizer however...

-- 
Alexander L. Belikoff
Bloomberg LP / BFM Financial Research Ltd.
abel@bfr.co.il