Is it unspecified behavior to compare pointers to different arrays for equality?

前端 未结 3 1525
一生所求
一生所求 2020-11-30 10:05

The equality operators have the semantic restrictions of relational operators on pointers:

The == (equal to) and the != (not equal to) operators have

3条回答
  •  难免孤独
    2020-11-30 10:37

    The semantics for op== and op!= explicitly say that the mapping is except for their truth-value result. So you need to look what is defined for their truth value result. If they say that the result is unspecified, then it is unspecified. If they define specific rules, then it is not. It says in particular

    Two pointers of the same type compare equal if and only if they are both null, both point to the same function, or both represent the same address

提交回复
热议问题