"pointer to an object type"与"pointer to a void"比较相等时如何理解转换规则?

How to understand the conversion rule when a "pointer to an object type" compares for eqality with a "pointer to a void"?

n1570 6.5.9.5 (Equality operators) 说:

5 ......If one operand is a pointer to an object type and the other is a pointer to a qualified or unqualified version of void, the former is converted to the type of the latter.

如果"former"是"latter"是"pointer to object type"和"pointer to a void",那么表示转换后比较发生在两个void*上,根据 6.5.9.2,未定义:

2.One of the following shall hold:

both operands have arithmetic type;

both operands are pointers to qualified or unqualified versions of compatible types;

one operand is a pointer to an object type and the other is a pointer to a qualified or unqualified version of void; or

one operand is a pointer and the other is a null pointer constant.

这是N1570的语言缺陷吗?

我没想过从这个角度,但我的理解是,两个void *是(转换后,根据相等运算符属性)兼容类型。

我参考的是

"- both operands are pointers to qualified or unqualified versions of compatible types;"

If "former" is "latter" are "pointer to object type" and "pointer to a void", then it means, after the conversion, the compare happens on two void*s,

是的,我确实是这样读的。

which according to 6.5.9.2, is undefined:

没有。您引用了该标准的第 6.5.9.2 节,显然是相信您所询问的案例未包含在该节的备选方案枚举列表中,但您错了。此备选方案涵盖案例:

one operand is a pointer to an object type and the other is a pointer to a qualified or unqualified version of void;

这里重要的是要理解指向void 的指针是指向对象类型的指针,对于

The void type comprises an empty set of values; it is an incomplete object type that cannot be completed.

(6.2.5/19;已强调)

6.5.9.2 不应被解释为暗示 void 不是对象类型;相反,它说 void *all 对象指针类型相当,当然包括它本身。

正如@SouravGhosh 首先观察到的,此替代方案也涵盖了所讨论的情况:

both operands are pointers to qualified or unqualified versions of compatible types

因为每种类型都与自身兼容 (6.2.7/1)。