Path: utzoo!utgpu!water!watmath!clyde!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: no noalias not negligible Message-ID: <4152@haddock.ISC.COM> Date: 23 May 88 23:48:14 GMT References: <54080@sun.uucp> <1988May21.030207.25063@light.uucp> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 30 In article <1988May21.030207.25063@light.uucp> bvs@light.UUCP (Bakul Shah) writes: >In article <54080@sun.uucp> dgh%dgh@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 ... The information is there, and a human reader can prove it, but I don't think they make compilers that smart yet. >note that in a sense this is an explicit translation of fortran's [rule] Actually, a better translation might be assert(!overlap(dx, dy, n)); (though we'd need a slight change to the definition of assert to make this useful for optimization). >extern int daxpy(int n, double da, double dx[], double dy[]) > /* call */if (!overlap(dx, dy, n)); >The syntax is unambiguous... But it differs from currently-legal syntax only by the absence of a semicolon separating the lines. For that reason, i'd prefer something else. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint