Kacheong Poon <Kacheong.Poon at Sun.COM> wrote:

> I have a question about lint warning on the following code.
>
> int foo(void)
> {
>   ...
> }
>
> int bar(void)
> {
>     int a[foo()];
>     ...
> }
>
> Lint complains that the return value of foo() is ignored.
> Isn't the above a valid way to use the variable-length
> array feature (assuming it will not cause stack overflow)?

Variable length arrays do not help to avoid stack overflows.
VLAs should not be used if you don't know at compile time that the
actual size will always be within reasonable bounds.

Regarding the principle correctness of the code, I believe that this should 
work.



J?rg

-- 
 EMail:joerg at schily.isdn.cs.tu-berlin.de (home) J?rg Schilling D-13353 Berlin
       js at cs.tu-berlin.de                (uni)  
       joerg.schilling at fokus.fraunhofer.de (work) Blog: 
http://schily.blogspot.com/
 URL:  http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily

Reply via email to