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]

bug, sizeof large union


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.

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