What should "sizeof (expression)" return? Why "8" ??

Michael Greim greim at sbsvax.UUCP
Wed Dec 7 01:44:46 AEST 1988


Hello,

Just recently I tried the following program:
---- cut ----
# include <stdio.h>

struct misty {
	unsigned int a1:1;
	unsigned int a2:15;
};
struct misty mist;
char c1, c2;
int i;
float r;
char s [20];

main ()
{
	printf ("sizeof(mist.a1) [1 bit] = %d\n", sizeof(mist.a1));
	printf ("sizeof(c1<c2) = %d\n", sizeof(c1<c2));
	printf ("sizeof(i+r) = %d\n", sizeof (i+r));
	printf ("sizeof(i+s) = %d\n", sizeof (i+s));
}
---- cut ----
It printed

sizeof(mist.a1) [1 bit] = 4
sizeof(c1<c2) = 4
sizeof(i+r) = 8
sizeof(i+s) = 4

This was on a VAX 11/780 running 4.3BSD.

Now comes my question:
What should "sizeof expression" return? And specially : why does it
return 8 for the third expression?

Thanks for any answers,
	-mg
-- 
email : greim at sbsvax.informatik.uni-saarland.dbp.de
  (some mailers might not like this. Then use greim at sbsvax.uucp)
  or  : ...!uunet!unido!sbsvax!greim
# include <disclaimers/std.h>



More information about the Comp.lang.c mailing list