Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added description

According to the WG14 document:

     Given an integer expression E, the derived type T of E is determined as follows:

               - if E is a sizeof expression, then T is the type of the operand of the expression;

               - otherwise, if E is an identifier, then T is the derived type of the expression last used to store a value in E;

               - otherwise, if the derived type of each of E's subexpressions is the same, then T is that type;

               - otherwise, the derived type is an unspecified character type compatible with any of char, signed char, and unsigned char.

Note: 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 those examples.

Effective size of a pointer is the size of the object to which it points.

Wiki Markup
     Example:                                     int arr\[5\];

                                                        int *p = arr;

The effective size of the pointer 'p' in this example will be sizeof(arr) i.e. 5*sizeof(int).

Effective type of an object is 

Description

According to C standard - 6.2.5 Types, 

C library functions that make changes to arrays or objects usually take at least two arguments: i.)  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. 

...

API00-C. Functions should validate their parameters - https://www.securecoding.cert.org/confluence/display/seccode/API00-C.+Functions+should+validate+their+parametersImage Removed

WG14 Document: N1579 - Rule 5.34 Forming Invalid pointers by library functions.

...