I really don't understand what is happening with the code below. Why is
uint64_t t1 = MAXDWORD; // t1 contains 4294967295 - CORRECT uint64_t t2 = t1 + 1; // t2 contains 4294967296 - CORRECT uint64_t t3 = MAXDWORD + 1; // t3 contains 0 (zero) - HUH??
decltype(MAXDWORD) is a narrower type than
uint64_t. So the expression
MAXDWORD + 1 is not a
uint64_t either, and
unsigned wraparound behaviour is observed prior to the assignment to
t1 + 1 is performed in
unsigned arithmetic using the
uint64_t type, which is wider.