Hi,
using one simple list, located in the external sdram device, the program is not able to figure out if the pItemNext from the list is defined or not... Therefore I always get an data abort error.
LISTITEM* pItemNext = (LITEM*)0; /* the first item in the list will be defined... */ /* second item in the list is not defined; the value of pItemNext = 0xE59FF018 */ pItemNext = pItem->pNextItem; /* while loop will be executed for this item which is not defined*/ while(pItemNext != (LITEM *)0) { /* -> data abort error */ pItemNext->data -= 1; pItemNext = pItem->pNextItem; }
How is it possible to get the while loop working? At the moment the while-loop will be executed for the pItemNext = 0xE59FF018... which is wrong.
best regards Hannes
make sure that the next element after a newly added one is a null pointer...?
also pay attention to the fact that this has nothing at all to do with C-like "definition", just illegal memory accesses.
Of course!
Adding an element to a list (any list) must ensure that the list remains entirely valid - which must include ensuring that the list remains correctly terminated!
This is basic stuff - nothing specifically to do with ARM or Keil.
Very true!
On your ARM target, it happens to result in a "data abort error"; on a PC, it could give a "General Protection Fault"; etc, etc,...
If it so happened tha the uninitialised pointer happened to point to some "real" memory, you would get all sorts of weird & wonderful bugs due to data corruption...
Hi, since the variable is not initialized, its value is unpredictable.
This also occurs, if you e.g. use integer variables:
int i = 1; int j; int z; z = i + j; // since j is not initialized, the value of z is also unpredictable
In a linked list, it is quite likely that this is not a "variable" at all; ie, not created at compile-time by the compiler - rather, it is quite likely that this is dynamically allocated.
But, yes - any pointer must be initialised before it is used!!