3 ms·
N.B. nonzero bitpattern nullptrs are common in C++ for pointer-to-member s, which are typically implemented as an offset from the start of the structure - with
by MaulingMonkey 4y ago
N.B. nonzero bitpattern nullptrs are common in C++ for pointer-to-member s, which are typically implemented as an offset from the start of the structure - with an all-0 bitpattern being a valid non-null pointer to the first member of said structure.
struct S { int i; };
int S::*a = &S::i; // probably 0 under the hood
int S::*b = nullptr; // probably -1 under the hood
int S::*c = 0; // probably -1 under the hood (no typo!)
Consider using brace initializers as an ergonomic alternative:
struct S d = { 0 };
struct S e = {}; /* as of C23 or C++ */