This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Not conform to c90?
- From: "Bingfeng Mei" <bmei at broadcom dot com>
- To: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Tue, 4 Oct 2011 04:09:03 -0700
- Subject: Not conform to c90?
Hello,
According to http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/Zero-Length.html#Zero-Length
A zero-length array should have a length of 1 in c90.
But I tried
struct
{
char a[0];
} ZERO;
void main()
{
int a[0];
printf ("size = %d\n", sizeof(ZERO));
}
Compiled with gcc 4.7
~/work/install-x86/bin/gcc test.c -O2 -std=c90
size = 0
I noticed the following statement in GCC document.
"As a quirk of the original implementation of zero-length arrays,
sizeof evaluates to zero."
Does it mean GCC just does not conform to c90 in this respect?
Thanks,
Bingfeng Mei