Must useless expressions be evaluated?

Spencer W. Thomas thomas at utah-gr.UUCP
Thu Oct 20 14:21:08 AEST 1983

But all of these examples (touching and/or reading a location to cause a
"trap") can be done in a "non-useless" setting by a statement of the form
	i := loc;
Here, you are assigning the value, and so it is not "useless".  In fact,
I had exactly that problem in a sort of garbage collector thing I wrote
- I wanted to test pointers to see if they really pointed to something
before following them.  Just saying *ptr was NOT sufficient - the
compiler threw it away (I think this was in a comma-separated
expression, I'm not sure now).  I had to actually assign it to a
variable before I could get my "expected" trap (naturally I chose a
register variable).


More information about the Comp.lang.c mailing list