Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!uw-beaver!apollo!mrst!sdti!turner From: turner@sdti.UUCP (Prescott K. Turner) Newsgroups: comp.lang.c Subject: Re: no noalias not negligible Summary: test idea not standard Message-ID: <275@sdti.UUCP> Date: 27 May 88 03:59:00 GMT References: <54080@sun.uucp> <1988May21.030207.25063@light.uucp> Reply-To: turner@sdti.UUCP (Prescott K. Turner, Jr.) Organization: Software Development Technologies, Sudbury MA Lines: 21 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 ... 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