This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c99 VLA semantics


On Thu, 15 Jun 2006, Mike Stump wrote:

> Here are just a few more issues I was wondering about for VLAs:
> 
> static int i;
> static int new_i() { i++; return i; }
> static int bar(int a[new_i()][new_i()]);

Same as static int bar(int a[*][*]);.  (In a definition, the two calls to 
new_i() happen in an unspecified order, but do not overlap and there is a 
sequence point between them, namely that at the end of the first call of 
new_i().  Both calls happen even though one array dimension disappears in 
the array-to-pointer parameter adjustment; GCC correctly handles 
side-effects in array dimensions lost by this adjustment and there's at 
least one old test in the testsuite to that effect.)

> void foo(int n) {
>  /* Presently an error, but, should it be (due to bar having a VM type and bar
> having other than no linkage)? */
>  extern int bar(int a[new_i()][new_i()]);
>  /* Same question. */
>  extern void foo2(int i[n][n]);

I don't think it can be intended that functions with VM arguments 
themselves have VM type (otherwise you'd have problems declaring them at 
all since they don't have no linkage and may have file scope).  But the 
definition in terms of contained declarators hardly makes things clear.  I 
would say, however, that while VM-ness shouldn't propagate out from 
function argument types to the type of the function, it should so 
propagate from the function return type to the type of the function.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]