ПК
Size: a a a
ПК
m
std::byte* buf = new std::buf[2];
std::uintptr_t i = static_cast<std::uintptr_t>(buf);
std::byte* b0 = static_cast<std::byte*>(i); // OK
std::byte* b1 = static_cast<std::byte*>(i+1); // UB
S
ПК
⛧
IK
S
IK
S
std::byte* buf = new std::buf[2];
std::uintptr_t i = static_cast<std::uintptr_t>(buf);
std::byte* b0 = static_cast<std::byte*>(i); // OK
std::byte* b1 = static_cast<std::byte*>(i+1); // UB
static_cast
а reinterpret_cast
m
IK
S
m
if (p)
или if (p != 0)
компилятор будет делать сравнение с nullptr, а не битовыым нулем.AD
nullptr
и можно ли его разыменовывать.AB
AB
S