“Your program not crashing can make the problem seem benign. It is not.”

A static_cast<int> on an out-of-range float is undefined and the compiler stays silent about it, even under -Wall -Wextra. It appears to work because x86 and AArch64 happen to produce something consistent, which lasts until a different target or a smarter optimizer shows up. Microsoft’s own gsl::narrow carries the bug despite documentation claiming otherwise. Bounds check before the cast and turn on -fsanitize=float-cast-overflow.