v
== (uintptr_t)(void*)0
. Без такого каста вряд лиSize: a a a
v
== (uintptr_t)(void*)0
. Без такого каста вряд лиAB
AP
AP
v
[basic.stc.dynamic.safety]
написано про safely-derived pointer to an object with dynamic storage duration
и integer representation of a safely-derived pointer
и что их можно друг в друга реинтерпрет кастовать. Про указатели на статические или автоматические объекты не написано. А реинтерпрет каст вызывает конвертацию по правилам [expr.reinterpret.cast]
, т.е. impl defined.A pointer can be explicitly converted to any integral type large enough to hold all **values** of its type. The mapping function is implementation-defined. A value of type std::nullptr_t can be converted to an integral type; the conversion has the same meaning and validity as a conversion of (void*)0 to the integral type.Теперь все понятно.
A value of integral type or enumeration type can be explicitly converted to a pointer. A pointer converted to an integer of sufficient size (if any such exists on the implementation) and back to the same pointer type will have its original **value**; mappings between pointers and integers are otherwise implementation-defined. [Note: Except as described in 6.7.5.4.3, the result of such a conversion will not be a safely-derived pointer value.
auto n = (std::uintptr_t)(void*)0;
n == (std::uintptr_t)(void*)0; // правильно
n == (std::uintptr_t)0; // неправильно
ЮП
DS
A
ПК
AB
АК
C