...
- The first rule from the above definition is applied to non-compliant code/compliant solution 2 and 4 in this page to calculate the derived type of expression 'n' is in those examples.
Effective size of a pointer is the size of the object to which it points.
...
C library functions that make changes to arrays or objects usually take at least two arguments: i.) a a pointer to the array/object ii.) an integer indicating the number of elements or bytes to be manipulated. If the arguments are supplied improperly during such a function call, the function may cause the pointer to not point to the object at all or point past the end of the object. This would lead to undefined behavior.
...
- For func (p,n), where 'p' is the a pointer, 'n' is the an integer and 'func' is the a library function, the value of ânâ should not be greater than the effective size of the pointer. Also, in situations where 'n' is an expression (see non-compliant code/compliant solution 2 below) the effective type of the pointer should be compatible with either the derived type of 'n' or unsigned char.
- For func (p,q, n), where 'p' and 'q' are both pointers, 'n' is the an integer and 'func' is the a library function, the value of ânâ should not be greater than the effective size of any of the two pointers ('p' and 'q'). The effective type of the 'p' should be compatible with the derived type of 'n' or unsigned char when 'n' is an expression. Similarly, the effective type of the 'p' should be compatible with the effective type of 'q' or unsigned char.
- For expression E of the form: T* q = func (n), where 'func' is a memory allocation function, the value of 'n' should not be less than sizeof (T). Also, the effective type of 'T' should be compatible with either the derived type of 'n' or unsigned char.
...