Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: James Kuyper Newsgroups: comp.lang.c Subject: Re: Size of an arraylist in bytes Date: Sat, 04 Feb 2012 17:32:18 -0500 Organization: A noiseless patient Spider Lines: 36 Message-ID: <4F2DB1F2.3@verizon.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Injection-Info: mx04.eternal-september.org; posting-host="2P71cupDoazVVolqpw1jrw"; logging-data="14280"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Q1hXknRG4Nti2wC7Lz17wlz4BAlYi7pE=" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:9.0) Gecko/20111220 Thunderbird/9.0 In-Reply-To: Cancel-Lock: sha1:IQoRGVYCZkq0FoVSwiXXftrwcJk= Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:16689 On 02/04/2012 04:25 PM, Joe keane wrote: ... > int g(int x) > { > int a[4][5]; > int *p; > int *q; > int j; > > p = &a[0][5]; > q = &a[1][0]; > if (p != q) > barf(); > *p = 2;; > *q = 3;; What's with the double semi-colons? Because dereferencing p has undefined behavior, a conforming implementation of C can do anything it wants with this code. However, in particular, it need not pay any attention to the fact that p and q point at the same location. It could therefore rearrange the order of the previous two lines, which would produce unexpected results on the following line: > j = *p; > if (j != 3) > puke(); > } > > I'm looking for 'reductio ad absurdum'. > > i.e., chapter and verse for 'this can't possibly not work' It can work; but it's not required to work - which is the point.