I am using PolySpace to analyze some autogenerated code which iterates a pointer over a struct as follows.
*(&StructVar.destValue) = *((&StructVar.destValue)+1);
For the testcase, the target was set to 8-bit in order to exclude an alignment problem.
I have also verified that calls are ANSI C compliant from the compliance documentation for C99-Standard ISO/IEC 9899:TC3, Page 115, Sentence 13 which states the following:
Within a structure object, the non-bit-field members and the units in which bit-fields reside have addresses that increase in the order in which they are declared. A pointer to a structure object, suitably converted, points to its initial member (or if that member is a bit-field, then to the unit in which it resides), and vice versa. There may be unnamed padding within a structure object, but not at its beginning.
However, on running the analysis, I receive the red check on this code with the following error:
Error : pointer is outside its bounds
On using the -allow-ptr-arit-on-struct option I receive an orange:
Warning : local variable may be non-initialized (type: int 8)
I expect a green check on this construct since it is ANSI-compliant.
Best Answer