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: absence of max Date: Thu, 01 Dec 2016 14:48:05 -0800 Organization: None to speak of Lines: 53 Message-ID: References: <0e1db67d-0ab8-4971-a319-8aa66a40b873@googlegroups.com> <436aadfe-20e5-4349-bdf4-9bac145b0d7e@googlegroups.com> <87oa0zi280.fsf@bsb.me.uk> <871sxvhw4i.fsf@bsb.me.uk> <87a8ch18kc.fsf@bsb.me.uk> <874m2o22jy.fsf@bsb.me.uk> <4894f89e-1b6a-4a7e-97b5-e12c9734da41@googlegroups.com> <8e947169-6c71-4977-b6fd-bb7a1185994b@googlegroups.com> <422c6643-4e2d-4b71-8937-434aad03bff9@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="e9e90b81bc42428c034e25748a0d26e9"; logging-data="16102"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WCEAu4jP4kJVP7IyEXU9Z" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:xQ6mYrE5PTWBTgs3WxtVObFa9w4= sha1:o3dioidwqpM0F9cCe4dqHA6JAgw= Xref: csiph.com comp.lang.c:97853 supercat@casperkitty.com writes: > On Thursday, December 1, 2016 at 2:52:37 PM UTC-6, Keith Thompson wrote: >> supercat writes: >> > I know what "int foo(int *restrict p)" means. I don't see anything, >> > however, that suggests that "int foo(int p[restrict])" would mean the >> > same thing. Given that the meaning of a "static" qualifier in an array >> > bound is totally different from its meaning in other contexts, and I >> > can't think of any cases where a qualifier within an array bound would >> > be applied to the array, I see nothing in the Standard which would >> > describe the meaning of the syntax using "[restrict]", beyond the fact >> > that its inclusion in an example suggests that it must be regarded as >> > valid and should probably mean something. >> >> N1570 6.7.6.3p7: >> >> A declaration of a parameter as "array of type" shall be adjusted >> to "qualified pointer to type", where the type qualifiers (if >> any) are those specified within the [ and ] of the array type >> derivation. If the keyword static also appears within the [ >> and ] of the array type derivation, then for each call to the >> function, the value of the corresponding actual argument shall >> provide access to the first element of an array with at least >> as many elements as specified by the size expression. >> >> "restrict" is a type qualifier, so a parameter declaration >> int p[restrict] >> is equivalent to >> int *retrict p > > Thanks. I wonder what the reasoning was behind that rule; the rule > appears as 6.7.5.3p7 in C99 [found by searching for the language > therein], and nothing in the C99 rationale for 6.7.5.3 seems to mention > it; it seems like a purely redundant way of expressing something that > could be easily expressed in another fashion, precluding the use of the > syntax for some other different purpose. The "static" syntax can only be used with array syntax. Allowing other qualifiers as well means the features can be combined, for example void func(char [restrict static 10]); > In any case, since the syntax as defined in the fashion you indicate, that > would suggest that C does as I said lack any concept of "pointer to the > start of an array of unknown size". Isn't that pretty much what an object pointer is, given that any object can be treated as a single-element array as far as pointer arithmetic is concerned? -- 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"