Another silly question
Guy Harris
guy at auspex.auspex.com
Fri May 19 02:53:32 AEST 1989
> When "+" denotes simple (ie int/float/etc) arithmetic, the
> operation commutes; when it denotes pointer arithmetic,
> commutation is not legal/meaningful.
Funny, X3J11 disagrees with you:
3.3.6 Additive operators
...
Semantics
...
...In other words, if the expression "P" pointers to the "i"th
element of an array object, the expressions "(P)+N"
(equivalently, "N+(P)")...
> The statement that *(a+i) == *(i+a) is therefore invalid.
The statement that "The statement that *(a+i) == *(i+a) is therefore
invalid" is therefore invalid.
It may make life miserable for compiler writers, but if so they should
have lobbied X3J11; it's probably too late now - go forth and fix your
compiler, if it can't cope with "i[a]".
More information about the Comp.lang.c
mailing list