Question of Ignorance

Alan Rooks alan at oscvax.UUCP
Sun May 12 09:59:03 AEST 1985


David Anthony was wondering why Alcyon Corp's C compiler scales constants in:

if (ptr == CONSTANT) ...

Maybe Alcyon's justification for this is that (they think) it is equivalent to:

if (ptr - CONSTANT == 0) ...

which is generally true in comparisons, but not with pointers. So when they
subtract the constant from the pointer, they have to scale it, as per
K&R page 189. The funny thing is, they don't generate code with a subtraction
and a compare against zero (and it would be a shame if they did) ...

Alan Rooks, Ontario Science Centre



More information about the Comp.lang.c mailing list