Suppose I have two arrays:
uint8_t buf1[10];
uint8_t buf2[20];
I now want to create an array of these arrays, e.g.,
uint8_t *buffers[] = {buf1, buf2};
When I look at the buffers variable in the debugger, however, I see that its two elements do not point to any elements of buf1 and buf2, but look like random values (maybe the contents of buf1/buf2?). Also, when dereferencing, e.g.,
uint8_t x = *(buffers[0] + 1);
the programs throws a bus error.
If I change the definition to
uint8_t *buffers[] = {&buf1[0], &buf2[0]};
everything is alright.
Why is there a difference? I always thought that array and &array[0] are equivalent?! What is the correct type of buffers to make definition 1 work?
EDIT: OK, I goofed up. There is in fact no difference between definition 1 and 2. I'm not really sure what change I did to see the correct values, but I do have a screenshot.
Anyway, I now know the answer to my question why the pointers are all bad, but you couldn't know because I stripped an important detail from the question.
I added __attribute__((section(".foo"))) to the definition of buffers, and that segment foo is uninitialized. Of course the values are random!
Sorry for wasting your time. :-)

#includes andint main()etc. that allows to reproduce the "bus error". Please specify the compiler and compiler options used and, if relevant, the target machine you are running this on. Please read how do you ask a good question on stackoverflow and helpful to me stackoverflow question checklist. I want to experience the same bus error on my computer too, what should I do?uint8_t *buffers[] = {buf1, buf2};is equivalent touint8_t *buffers[] = {&buf1[0], &buf2[0]};.(buffers[0] + 1)is equivalent to&(buf1[1]), so*(buffers1[0] + 1)isbuf1[1]. Of course that may or may not be what larsb intended.