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]

int a[0]={2};


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





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