sizeof() confusion

Larry Jones scjones at thor.UUCP
Fri Nov 16 06:00:52 AEST 1990


In article <1990Nov14.154213.27324 at cbnewsj.att.com>, asd at cbnewsj.att.com (Adam S. Denton) writes:
> You take sizeof() of an object, not an expression.

Sorry, wrong answer.  sizeof is an operator just like +, %, or -> --
its operand most certainly IS an expression.  sizeof (a * b / c) is
every bit as valid as sizeof a (or sizeof(a) for those who think it's
some kind of magic function rather than an operator).  The key point
(which someone else has already mentioned) is that expressions do not
undergo any conversions simply because they are expressions; rather,
the operands of each operator are converted according to the rules for
the particular operator.  So, although most operators convert an operand
which is an identifier into the corresponding value (i.e. convert an
lvalue into an rvalue), sizeof does not.
----
Larry Jones                         UUCP: uunet!sdrc!thor!scjones
SDRC                                      scjones at thor.UUCP
2000 Eastman Dr.                    BIX:  ltl
Milford, OH  45150-2789             AT&T: (513) 576-2070
I hope Mom and Dad didn't rent out my room. -- Calvin



More information about the Comp.lang.c mailing list