This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Variable Length Arrays in C, support as per C89/C99 in gcc


Hi,

I have a piece of code which looks like this ...

----------- listing begin ------------

#include <stdio.h>

int main()
{
	int b = 10 ;
	int a[b] ;

	b[0] = 12 ;
	b[1] = 89 ;
	b[2] = 78 ;

	printf("%d, %d, %d\n", b[0], b[1], b[2]) ;
}

----------- listing end ------------

I expected that this would not work with pure C89 compilers or
when I give the -std=c98 (or -std=iso9899:1990) to gcc. But it
looks like I am not correct (though "info gcc" says that giving
the -std=c98 or -ansi or -std=iso9899:1990 would comply to C89)

However, if I give the -pedantic option, I get a warning that
says ... "ISO C89 forbids variable-size array `b'" which is ok
but then what's with the above -std options?

I tried this with gcc 2.95.3 as well as 2.96. Any clues? Am I
doing anything incorrect here?

-best regards,
Giridhar

--
Y Giridhar Appaji Nag       Giridhar.Nag[@t]ubinetics(.)co.in

While one person hesitates because he feels inferior, another
is busy making mistakes and becoming superior. -Henry C. Link

> an individual are not necessarily those of UbiNetics


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]