Ralf Wildenhues <Ralf.Wildenhues <at> gmx.de> writes:

> OK, except for...
> 
> > -  int number[3];
> > +  int number[3] = {0};
> 
> this which won't initialize number[2].

Yes it will.  The C standard requires that all unspecified array members be 0-
initialized if at least the first array member is explicitly initialized:

$ cat foo.c
#include <stdio.h>
int main()
{
   int number[3]
#if INIT
      = {0}
#endif
   ;
   return printf("%d %d %d\n", number[0], number[1], number[2]);
}
$ gcc -Wall -O2 -o foo foo.c
$ ./foo
1628854574 47 2086312361
$ gcc -Wall -O2 -o foo foo.c -DINIT=1
$ ./foo
0 0 0


-- 
Eric Blake




_______________________________________________
M4-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/m4-patches

Reply via email to