public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* GCC-ANSI C conflict
@ 2005-06-16 4:35 Sankara Rameswaran
2005-06-16 11:39 ` Andrew Pinski
0 siblings, 1 reply; 2+ messages in thread
From: Sankara Rameswaran @ 2005-06-16 4:35 UTC (permalink / raw)
To: GCC BUGS
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
>>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++...
please clarify
expecting a reply...
--
Sankara Rameswaran,
Give more your ears less your voice
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: GCC-ANSI C conflict
2005-06-16 4:35 GCC-ANSI C conflict Sankara Rameswaran
@ 2005-06-16 11:39 ` Andrew Pinski
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Pinski @ 2005-06-16 11:39 UTC (permalink / raw)
To: Sankara Rameswaran; +Cc: GCC BUGS
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-06-16 11:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-16 4:35 GCC-ANSI C conflict Sankara Rameswaran
2005-06-16 11:39 ` Andrew Pinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).