This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Sizeof behaves incorrectly with some unions
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Sizeof behaves incorrectly with some unions
- From: Jason Stokes <jstok at bluedog dot apana dot org dot au>
- Date: Tue, 14 Nov 2000 17:40:44 +1100
Trying the code:
struct formata {
int opmode: 3;
int opcode: 3;
};
struct formatb {
int opcode: 6;
};
union format {
struct formata;
struct formatb;
};
union simple {
char a;
double b;
};
.
.
.
.
printf("The size of union simple is %i\n", sizeof(union simple));
printf("The size of union format is %i\n", sizeof(union format));
Output:
The size of union simple is 8
The size of union format is 0
I'm using egcs-2.91.66 on Red Hat Linux 2.2.14.