This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: TI C/C++ Compiler
Hello Compiler Team,
I am using ARM compiler v16.9.3.LTS, and getting a MISRA warning that I do not understand. Here is a very simple example that re-creates the warning:
int foo(int *p);
int foo(int *p) {
return *p;
}
Building this in CCSv7.1 generates the following MISRA warning for the 'return' code line:
"C:/TI/ccsv7/tools/compiler/ti-cgt-arm_16.9.3.LTS/bin/armcl" -mv7R4 --code_state=32 -me --include_path="C:/Users/a0192908/motorware_CCS_v7/test" --include_path="C:/Users/a0192908/motorware_CCS_v7/test/include" --include_path="C:/TI/ccsv7/tools/compiler/ti-cgt-arm_16.9.3.LTS/include" -g --strict_ansi --diag_warning=225 --diag_wrap=off --display_error_number --enum_type=packed --abi=eabi --check_misra="required" --preproc_with_compile --preproc_dependency="source/foo.d" --obj_directory="source" "../source/foo.c"
"../source/foo.c", line 4: warning #1423-D: (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 ("p")
'Finished building: ../source/foo.c'
------------------
I don't see what the violation is. I am not assigned the address of anything. Rather, I am assigning the value pointed to by p as the return value.
If I write the code like this, the warning disappears:
int foo(int *p);
int foo(int *p) {
int x;
x = *p;
return x;
}
Can someone explain why the original code generates this warning?
Thank you,
David
David M. Alter said:Can someone explain why the original code generates this warning?
Unfortunately, I cannot. I filed CODEGEN-2275 in the SDOWP system to have this investigated. You are welcome to follow it with the SDOWP link below in my signature.
Thanks and regards,
-George