Assignment Ops and Side Effects

Doug Gwyn gwyn at smoke.brl.mil
Wed Apr 10 14:24:25 AEST 1991


In article <18355 at crdgw1.crd.ge.com> volpe at camelback.crd.ge.com (Christopher R Volpe) writes:
>In article <15765 at smoke.brl.mil>, gwyn at smoke.brl.mil (Doug Gwyn) writes:
>|>In article <18324 at crdgw1.crd.ge.com> volpe at camelback.crd.ge.com (Christopher R Volpe) writes:
>|>>The result of "c=1" in an expression context should be promoted to int.
>|>Not if it's the operand of sizeof; that would make sizeof rather useless.
>I don't think it would be useless at all. I could still do sizeof(c) and
>get the size of a char if I wanted. Can you point me to a reference to
>the Standard from which one can deduce that a NON-lvalue expression
>of type char should NOT be promoted to int when it is the operand of
>sizeof?

Yeah -- the whole damn standard.  It doesn't contain a specific
statement that says "Don't invent rules along the lines of Volpe";
instead it gives rules for properly determining what does happen:
3.3.16 Semantics:  The type of an assignment expression is the type of
the left operand...
3.3.3.4 Semantics:  The sizeof operator ... size is determined from
the type of the operand, which is not itself evaluated.
I see no room for for thinking that any sort of conversion should be
performed.



More information about the Comp.lang.c mailing list