Negative array size

The size of a variable size array is less than or equal to zero.

The C99 language extensions permit variable size arrays. Invalid attempts to allocate variable size arrays can lead to this error.

ID

Observation

Description

1

Definition

The place the array was defined

Example

          
#include <stdio.h>

int f(int size)
{
    int a[size];
    a[0] = 1;
    printf("%d\n", a[0]);
    return 0;
}

int main(int argc, char **argv)
{
    f(-1); // not good
    return 0;
}
        

Copyright © 2010, Intel Corporation. All rights reserved.