Sizeof behaves incorrectly with some unions

Jason Stokes jstok@bluedog.apana.org.au
Mon Nov 13 22:38:00 GMT 2000


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.


More information about the Gcc-bugs mailing list