Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Array-as-pointer Syntax Date: Thu, 28 Mar 2019 13:57:45 -0700 Organization: None to speak of Lines: 29 Message-ID: References: <761347c7-4f03-42f3-a156-5f357c8ae091@googlegroups.com> <4be1835e-b0cb-44ad-b088-ad8e82cde4f0@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="8cfa11d3fa0097ca58f89eca347894b2"; logging-data="32278"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/odo295n+gLtCPGRBmzzxb" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:TO0z8IsHrVuI0Hcc4EZJE0096nE= sha1:Y2ksBnNVU7vc1PNUkFWo7R3tZx0= Xref: csiph.com comp.lang.c:142566 James Kuyper writes: > On Thursday, March 28, 2019 at 1:04:43 PM UTC-4, David T. Ashley wrote: [...] > As an lvalue of array type, 'x' gets implicitly converted into a pointer > to the first element of that array, x[0], in most contexts (6.3.2.1p3), > including the following one: > >> memset(x, 0, sizeof(x)); >> >> and > > However, there are four exceptions to that rule, and &x is one of them > (the other three are as the operands of sizeof or _Alignof, or as a > string literal used to initialize an array of character type). This > results in a pointer to the entire array: > >> memset(&x, 0, sizeof(x)); There are three exceptions, not four. _Alignof (for unclear reasons) can only be applied to a parenthesized type name, not to an expression. Including _Alignof in the list of exceptions was an error in the N1570 draft, corrected in the published C11 standard. [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */