bug, sizeof large union
Mitsuhisa Sato
msato@trc.rwcp.or.jp
Thu Jun 29 22:23:00 GMT 2000
Hi,
I found a bug that 'sizeof' a large union is wrong.
If someone alreay reported, let me know how to fix it.
---
union A_ok {
char A[ 0xFFFFFFF];
};
union A_ng {
char A[0x10000000];
};
union A_ng x;
main()
{
printf("size A_ok=%x, size A_ng=%x\n",
sizeof(union A_ok),sizeof(union A_ng));
x.A[0xFFFFFFF] = 1;
}
---
I got results:
size A_ok=fffffff, size A_ng=0
Segmentation fault
'x' in bss is also not allocated correctly.
My gcc version is:
GNU C version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
(i386-redhat-linux) compiled by GNU C version egcs-2.91.66
19990314/Linux (egcs-1.1.2 release).
And my system is:
Linux version 2.2.12, Pentium II
I got the same result on :
Sun Enterprise 450 Sparc/Solaris, gcc version 2.95.2 19991024 (release)
Thanks,
-- M. Sato.
More information about the Gcc-bugs
mailing list