2 ms·
(B), assuming int is 32-bit and short is 16-bit. The multiplication promotes both operands and result to signed int, right? So if both x and y are uint16_max, t
by loeg 4y ago
(B), assuming int is 32-bit and short is 16-bit. The multiplication promotes both operands and result to signed int, right? So if both x and y are uint16_max, the result overflows signed int and is UB, I think.
But if int were larger (eg 64 bit) and short remained 16 bits, there’s no overflow and the answer is (A). I think.