What is Pointer Arithmetic

Pointer Arithmetic: C and C++ provide the ability to modify a pointer’s target address with arithmetic operations. This is used, for example, to index arrays.

MyObject* P = ...

...

P = P + 42;

For model checkers such as Java whose modeling notations do not support these operations directly, these operations can be problematic to model. For example a pointer variable can be mapped directly to a Java reference unless any pointer operations are performed on it anywhere in the code (e.g., pointer addition or taking its address). They require creation of explicit “C-pointer” objects with additional state (base, offset). We also need to create a model of the memory and the platform in order to be able to effectively model such arithmetic operations. While this can be supported in practice, it can significantly increase the complexity of the model and hence the size of the state space.

   Related Questions in Programming Languages

©TutorsGlobe All rights reserved 2022-2023.