It's not a bug -- you're relying on 32bit ints when OCaml has only
31bit ints (on 32-bit arch). In C (for example), if you use a plain
int (I believe it'll default to signed), you get the exact same
behaviour when the number overflows 2^31.
(Signed overflow is not legal in C (undefined behaviour), and a decent
compiler will warn this can be detected statically.)
Of course it is a bug - a design bug, since the behaviour is intended
and documented, but still a bug. But getting numbers, even integers,
right in every respect is hard, and involves trade-offs between
performance, correctness and convenience.
I would love to have a fast unboxed integer type that automatically
overflows to bignum, but it would be a tad slower than the current "int".