This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: int a[0]={2};
- To: Klaus Niederkrueger <klaus at momo dot math dot rwth-aachen dot de>
- Subject: Re: int a[0]={2};
- From: Kip Macy <kip at lyris dot com>
- Date: Wed, 18 Aug 1999 10:58:18 -0700 (PDT)
- cc: gcc-bugs at gcc dot gnu dot org
g++ 2.7.2 or 2.95 will give an error:
test.c: In function `int main()':
test.c:6: excess elements in aggregate initializer
On Wed, 18 Aug 1999, Klaus Niederkrueger wrote:
> 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
>
>
>
>
>
>