Can we subtract NULL pointers?
问题 Since pointer arithmetic is defined within the same array I'm in doubt if we can subtract NULL from another NULL . I'm concerned about the implementation of: //first and second can both either be from the same array //or be both NULL prtdiff_t sub(void *first, void *second){ //Do I really need this condition? if(!first && !second) return (ptrdiff_t) 0; return second - first; } 回答1: Subtracting two NULL pointers is not allowed. Section 6.5.6p9 of the C standard states: When two pointers are