limitations of cast, pointers, &c...

Thomas M. Breuel breuel at harvard.ARPA
Thu Nov 1 23:52:47 AEST 1984


Thanks for your replies. Casting the lhs of an assignment might be
defined in an unambiguous way as, for example:

(type)x = y; <=> *(type *)&x = y;

which would be useful and unambiguous, but different in meaning from
a cast as it is usually used. It might also be defined as:

(ytype)x = y; <=> x = (xtype)y;

where xtype and ytype refer to the types of x and y respectively, and
where the construct is undefined if the cast on the lhs is not to the type
of the expression on the rhs.

In a similar manner it would also be possible to fill 'typedef ref *ref;'
with meaning. At any rate, replacing the dereferencing operator
'*' by '#define deref(x) *(ref *)x' gives the type 'ref' the desired
properties and thereby solves my problem.

				Yours sincerely,
				Thomas.

				(breuel at harvard.arpa)



More information about the Comp.lang.c mailing list