no noalias not negligible

Prescott K. Turner turner at sdti.UUCP
Fri May 27 13:59:00 AEST 1988


In article <1988May21.030207.25063 at light.uucp> bvs at light.UUCP (Bakul Shah) writes:
>In article <54080 at sun.uucp> dgh%dgh at Sun.COM (David Hough) writes:
>>Anyway there is no portable way in draft ANSI C to say "this pointers are
>>guaranteed to have no aliases".
>
>How about adding a test before the for loop?  Something like:
>#define overlap(x,y,n)    (!(x + n <= y || y + n <= x))
>       if (overlap(dx, dy, n))
>               return complain("overlapping arrays\n");
>
>Now a smart compiler can figure out that dx, dy don't overlap ...

This test make non-standard assumptions.  In draft ANSI C,
those pointer comparisons are undefined (meaning your program might
crash and burn) unless "x" and "y" point within the same object.
Anyone know a machine where this could be experienced?
--
Prescott K. Turner, Jr.
Software Development Technologies, Inc.
375 Dutton Rd., Sudbury, MA 01776 USA        (617) 443-5779
UUCP:genrad!mrst!sdti!turner



More information about the Comp.lang.c mailing list