https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57503

--- Comment #18 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Georg-Johann Lay from comment #17)
> Obervation that -fno-wrapv also leads to correct code, hence there is
> somewhere a wrong assumption that signed overflow occurs (which doesn't).

(you probably meant -fwrapv instead of -fno-wrapv?)
Why do you say wrong?
unsigned ab = a * b;
in C, that means:
unsigned ab = (int)a * (int)b;
Since a is in [0, 255], so is (int)a. Multiplication may not overflow for a
signed type, so (int)a*(int)b must be nonnegative. Converting it to long
directly or through unsigned int is thus equivalent.

Reply via email to