This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Dimensions of array parameters
Hi,
Ian Lance Taylor <iant@google.com> skribis:
> ludovic.courtes@inria.fr (Ludovic CourtÃs) writes:
>
>> "Joseph S. Myers" <joseph@codesourcery.com> skribis:
>>
>>> On Fri, 2 Dec 2011, Ludovic CourtÃs wrote:
>>>
>>>> Is there a way array dimension info could be preserved?
>>>
>>> Perhaps you could explain the actual problem you are trying to solve?
>>
>> Iâm just thinking that, if that information were preserved, GCC could do
>> static bound checking and/or generate bound checking code.
>
> The ABI for a C function does not provide any way to pass down the
> dimensions of an array.
I understand. However, Iâm concerned about keeping the information at
compile-time. For example:
extern void foo (int a, int x[a]);
static void bar (void) {
int x[123];
foo (456, x);
}
Here the compiler could emit a diagnostic in âbarâ.
IOW, ABI restrictions ABI imply that nothing can be done in the body of
âfooâ; however, the information could still used at call sites.
WDYT?
Thanks,
Ludoâ.