3 ms·
> Of course this is dangerous as it’s a narrowing conversion, with a cast which silences a legitimate warning. In C and C++ it invokes undefined behavior when g
by leni536 5y ago
> Of course this is dangerous as it’s a narrowing conversion, with a cast which silences a legitimate warning. In C and C++ it invokes undefined behavior when given specific large values and most certainly is exploitable. Most applications would just crash on inputs >= 0x7ffffffffffffffff.
No, it's not. Overflow on arithmetic is undefined, but on conversion it's implementation defined. In C++20 it's defined.