[C-Semantics] function prototype scope

Derek M Jones derek at knosof.co.uk
Sat Jun 18 12:28:12 CDT 2011


Chucky,

> int sub (int i, int array[i++]) {
...
> I'm pretty sure this is "function prototype scope" and that "i++" is

No it isn't.
Sentence 403: http://c0x.coding-guidelines.com/6.2.1.html
Also see sentence 408.

> not an integer constant expression, so it should be treated like a
> "*".  My understanding of the "*" in array declarators is fuzzy, but I
> don't think they are allowed to be used in a definition, only in a
> function declaration.  Indeed, all of the compilers complain with an
> error if I try:
>      int sub (int i, int array[*]) { ... }
> Instead, doing this:
>      int sub (int i, int array[*]);
>      int sub (int i, int array[10]) { ... }
> compiles and runs.
>
> If i++ is supposed to be evaluated (although I don't know how, based
> on the above 6.7.6.2:5), then when does it get evaluated?  During
> every call?  At definition time?  Are the side effects guaranteed to
> occur?  Where should I be looking in the standard instead of the
> quotes above?
>
> Does anyone know what is going on here?
>
> -Chucky
> _______________________________________________
> c-semantics mailing list
> c-semantics at cs.illinois.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/c-semantics
>

-- 
Derek M. Jones                         tel: +44 (0) 1252 520 667
Knowledge Software Ltd                 mailto:derek at knosof.co.uk
Source code analysis                   http://www.knosof.co.uk


More information about the c-semantics mailing list