Assignment Ops and Side Effects

Chris Torek torek at elf.ee.lbl.gov
Fri Apr 5 08:17:48 AEST 1991


In article <1991Apr4.202314.961 at csrd.uiuc.edu> bliss at sp64.csrd.uiuc.edu
(Brian Bliss) notes that on at least one system:
>	char ch;
>	sizeof (ch += 1) == 4
>	sizeof (ch++) == 1
>apparrently operands of ++ and -- do not undergo integral promotion

I am tempted to claim that this is a bug in the compiler in question,
but without the standard in front of me (I am reading news during
breakfast at home) I will go only as far as saying that, from a
reasonably abstract point of view,

	ch++

and

	ch += 1

should have the same type.  Gcc 1.39, for instance, makes them the same.
I doubt that gcc violates the standard in this regard, so either it is
undefined or implementation-defined as to exactly when promotion occurs
in assignment expressions, or else the compiler that gave you that
result is not conformant.
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427)
Berkeley, CA		Domain:	torek at ee.lbl.gov



More information about the Comp.lang.c mailing list