Note that this is not the same problem as reported in my other post http://e2e.ti.com/support/development_tools/compiler/f/343/t/89533.aspx#310031 (SDSCM00037487)
CGT 5.0.1
(MISRA-C:2004 17.6/R) The address of an object with automatic storage shall not be assigned to another object that may persist after the first object has ceased to exist
In the following code, the assignment of &myLocalStruct->data to myDataPtr in myFunc has MISRA 17.6 reported. myDataPtr only persists for the duration of the function, and therefore does not persist longer than data passed into that function.
typedef struct
{
uint8 data;
} Struct_T;
void myFunc(Struct_T *myLocalStruct);
void main(void);
void myFunc(Struct_T *myLocalStruct)
{
uint8 *myDataPtr;
myDataPtr = &myLocalStruct->data; /* (MISRA-C:2004 17.6/R) reported here
}
void main(void)
{
Struct_T myStruct = { 0U };
myFunc(&myStruct);
}
As an aside, I note that the following SDOWP reports on MISRA warnings have not been fixed in CGT 5.0.1 although they are reported as being fixed in older CGT releases 4.9 and 4.10. Please can you advise whether these will be addressed in CGT 5.x stream.
SDSCM00039420 Compiler issues unwarranted warning for violation of Misra 9.2 for zero initialization of multi dimensional arrays
SDSCM00038580 Incorrect violation of rule MISRA-C rule 6.1 is reported by the compiler
Regards, Tony