This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

pointer warnings

I get some strange warnings doing pointer arithmetic.

#include <stddef.h>
char x[3];
char *p=&x[3];
void foo(void)
{
  ptrdiff_t f1=p-&x[0];
  ptrdiff_t f2=p-x;
}
f1 is OK,
but f2 generates a warning
error C192: '=': value truncated


moreover, I noticed that ptrdiff_t is always typedefed as an int, which I think is not correct, especially for the XLarge memory model. I use the large model. maybe this has something to do with the warning, but I don't see why p-&x[0] is any different from p-x