Is this a VC compiler bug? About unsigned integer wrapping
gcc
and clang
both compile away that loop, replacing it with a printf of the constant 1
(using -O3
.)
I think the VC behaviour you observe is a bug: unsigned arithmetic is well-defined, and you're right that the overflow should wrap around to an integer less than 17. So gcc
and clang
get it right.