This is the mail archive of the gcc-bugs@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]

Re: GCC-ANSI C conflict



On Jun 16, 2005, at 12:35 AM, Sankara Rameswaran wrote:


hi
according to ansi c standards all declarations have to to be at the
starting of the block..
which means the program below should not work.. i compiled this using gcc

For C90 yes but not for C99.


gcc (GCC) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

but it is working fine.. this might be fine with g++ but i used gcc...

int main()
{
  int i;
  scanf("%d",&i);
  int a[i];
  a[i-1]=128;
  printf("%d",a[i-1]);
}

is this a bug or just for compatability with c++...

Not this is for C99 compatibility. In fact you are using VLAs which are part of C99
and not part of C++ at all.


Thanks,
Andrew Pinski


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