What does Z["ack"] = 5 mean?

kenny at m.cs.uiuc.edu kenny at m.cs.uiuc.edu
Tue Oct 11 02:07:00 AEST 1988


	I owe Messrs. Kernighan and Ritchie an apology for suggesting
that they were less than clear in specifying the behavior of the
subscript operator; there is a passage that states specifically that
subscripting is commutative, despite its asymmetric appearance.  That
passage, however, is the *only* indication that pointer arithmetic is
commutative (the fact is not mentioned in the context of the addition
operator), which may account for its having been missed by several
compiler writers.

	In any case, K&R second edition, Harbison & Steele, and the
dpANS have all added text clarifying the point, so perhaps we can lay
it to rest, except to remember that a number of compilers do it wrong,
and therefore to avoid the construct in code that is expected to be
portable.  Consider it `a common bug,' though, rather than `a flaw in
the specification.'



More information about the Comp.lang.c mailing list