Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Difference between these pointer syntaxes Date: Fri, 26 Aug 2016 09:07:47 -0700 Organization: None to speak of Lines: 58 Message-ID: References: <4628cd2d-9333-4be6-943a-eb593c5c4c12@googlegroups.com> <86fe4ec0-6dcd-4aa0-8a21-f8e57038c3bb@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="29311"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/C6Oswx/KrTcwfZ/6WeZtN" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:qx2V4WQmNtrJ7GCBDaMxCoG1nVE= sha1:SMpzej+KfmZFb/0lt5KEX4omTtw= Xref: csiph.com comp.lang.c:92732 BartC writes: > On 26/08/2016 14:36, Malcolm McLean wrote: [...] >> Arrays aren't technically arrays either. Yes, they are. >> the code >> >> double B[100]; >> double A[100]; >> >> B[0] = 42.0; >> >> for(i=0;i> A[i] = B[i]; >> >> is wrong. it is undefined behaviour. Yes, because 99 of the 100 elements of the array object B are uninitialized and have indeterminate values. >> A and B are buffers of 100 doubles, not arrays of 100 doubles. A and B are array objects, each consisting of 100 elements, each of which is an object of type double. >> B is an array of 1 double. No. > That's more of quibble. If you'd called some external function f(B,100) > just before the loop, then presumably B /might/ now be a full array > rather than a buffer? No, it's not a "quibble", it's simply wrong. The only way Malcolm's statement can be correct is if you accept his definition of the word "array", a definition that is entirely inconsistent with the way the C standard (and pretty much everyone else here) uses the word. [...] > The difference you're trying to highlight is more subtle and at a higher > level than just array vs. pointer. The difference he's trying to highlight is between an array object whose members are initialized and an array object whose members are not initialized. That's a valid distinction, but calling one of these "an array" and the other "not an array" is idiosyncratic, confusing, and wrong. [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"