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.

pointer points outside of underlying object

I'm getting the following warning:

pointer points outside of underlying object

when declaring a variable like this:

unsigned char *lpktoptr = packeto[16] + (unsigned int)(CHANNELS-8);

Read this thread but not sure if it is the same case or something different. 

In any case I could not figure out why is it happening. Any suggestions?

  • The compiler detected that lpktoptr points outside the array packeto. We cannot tell the exact reason without knowing the surrounding code, but here are a few suggestions:

    • packeto's length is less than 16 + (CHANNELS-8)
    • CHANNELS is less than 8, making (unsigned int)(CHANNELS-8) huge
    • CHANNELS is actually undefined, so that the compiler sees (unsigned int)(-8)

    Hope that helps

    Markus

  • Whoops, I saw an ampersand where there wasn't any. Are you sure you didn't mean to write "&packeto[16]"? What type is packeto?