This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
int a[0]={2};
- To: gcc-bugs at gcc dot gnu dot org
- Subject: int a[0]={2};
- From: Klaus Niederkrueger <klaus at momo dot math dot rwth-aachen dot de>
- Date: Wed, 18 Aug 1999 19:09:26 +0200
Hi,
I think I have found a small bug: Try this program on Linux
egcs-2.91.60 Debian 2.1 (egcs-1.1.1 release)
or
gcc version 2.7.2.3
.
------------------
int main()
{
int b= 5;
int a[0]={2};
printf("%i\n",b);
}
----------------------
On my machine the computer gives "2" as result instead of "5" and even if I
switch on "-Wall" I get no warning.
If I use the following program
--------------------
int main()
{
int b= 5;
int a[1]={2, 2};
printf("%i\n",b);
}
----------------------
I get the warning message at compile-time
test.c:4: warning: excess elements in array initializer after `a'
and the result is "5" as it should be...
I hope I am right and I don't waste your time.
Greetings
Klaus