![]() |
![]() |
3230 | ![]() |
||||
![]() | |||||||
| Pointers | REFERENCE - ISO:C90-6.1.2.4 Storage Durations of Objects | ||||||
The address of a local automatic object is being assigned to a local pointer which has static storage duration. This is dangerous. When the local object goes out of scope, the value obtained by dereferencing this pointer will be undefined. Perhaps this object needs to be declared with static storage duration also? For example:
/*PRQA S 2017,2211,3203,3223,3408,3447 ++*/
void f(void)
{
static int* pi;
int a;
pi = &a; /* Message 3230 */
}
MISRA-C:2004 Rules applicable to message 3230:
| Rule 17.6 (Required) | 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. |
See also:
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |