Path: utzoo!utgpu!attcan!uunet!mcvax!unido!sbsvax!greim From: greim@sbsvax.UUCP (Michael Greim) Newsgroups: comp.lang.c Subject: Summary of "What should sizeof(expression) return? Why 8?" Keywords: summary sizeof expression Message-ID: <657@sbsvax.UUCP> Date: 15 Dec 88 13:55:39 GMT References: <654@sbsvax.UUCP> Organization: Universitaet des Saarlandes, Saarbruecken, West Germany Lines: 54 Hello, In <654@sbsvax.UUCP> I asked several questions about what sizeof(expression) should return and why it returned certain values. This is a summary of responses. The questions were (printing was done on a VAX 11/780, running 4.3BSD) 1.) what is sizeof(bitfield of length 1)? Printed : 4 2.) what is sizeof(c1Simple. sizeof(expression) returns the size of the type of the expression. >In particular, the one which confused you was (i+r), adding an integer to a >float. Evidently your compiler takes the legal option of calculating all >floating-point expressions in double-precision. Therefore (i+r) is of type >double and sizeof returns 8. All K&R compilers did this conversion to >double-precision; ANSI C permits the calculation to be performed in >single-precision if the answer can be guaranteed to be exactly the same. The reason why I asked it in the first place was that I did not find the appropriate paragraph in K&R, so I thought that the return values were at least machine dependent and quite certainly undefined by C. Thanks to all the people who helped to educate me on this topic. -mg -- email : greim@sbsvax.informatik.uni-saarland.dbp.de (some mailers might not like this. Then use greim@sbsvax.uucp) or : ...!uunet!unido!sbsvax!greim # include