TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
C++ Coding Standard

Rule:  INT#030Checked automatically with code checker

Synopsis:Do not misuse a pointer when an array is requested
Severity Level:2
Category:Class Interface


When a pointer is used as reference to an array, it shall refer to an array of the correct type.


void Foo( int a[], int size )
    // do something with a; 
    for (int i = 0; i < size; i++) 
        a[i] = i;

int ar[] = {0,0,0};
Foo( ar, sizeof(ar)/sizeof(ar[0]) ); // Ok
int* ptr = &ar[1];
Foo( ptr, sizeof(ar)/sizeof(ar[0]) ); //Not allowed: passing pointer ptr in Foo causes out of array bounds.