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]

Sizeof behaves incorrectly with some unions


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.

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