I came across a piece of code that now works fine, but, in my opinion, its behavior is undefined and may lead to an error in the future.
Pseudocode:
void OpertateLoad(int load_id)
{
int value = 0;
SetLoadRequest(load_id,&value);
}
void SetLoadRequest(int load_id, int* value)
{
LoadsArray[load_id] = *value;
}
In my understanding, the C compiler does not guarantee where the variables will be stored Auto
. It can be a stack / register (if available and suitable for processing).
I suspect that if the compiler decides to save value
to the general register, then the function SetLoadRequest
may refer to incorrect data.
Did I understand correctly, or am I overdoing it?
I use a compiler IARARM
for the processor ARM CORTEX M-4
.
----------: EDIT: ----------
. , " , , , ".
: ? , ? '.
NO, - C, ? , undefined?