------- Comment #15 from rogerio at rilhas dot com 2010-08-12 16:15 ------- (In reply to comment #14) > I never claimed p1 and p2 have different types. They have the same type. > But the standard paragraph I mentioned says: > "When two pointers are subtracted, both shall point to elements of the same > array object, or one past the last element of the array object" > That is not the case in your testcase, strp and i are different objects.
char* p1=random_address(); char* p2=another_random_address(); p1-p2 is always well defined, no matter to which objects they point to. After the subtracion they will point to objects of the same type (char's). So, you don't know your C nor C99 (we are reading it wrong). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45265