Georg-Johann Lay <gjl at gcc dot> changed:

           What    |Removed                     |Added
           Keywords|wrong-code                  |diagnostic
            Summary|[6/7/8 Regression] Wrong    |Missing warning for signed
                   |extension of multiply       |overflow
                   |operand                     |

--- Comment #20 from Georg-Johann Lay <gjl at gcc dot> ---
(In reply to Marc Glisse from comment #18)
> (In reply to Georg-Johann Lay from comment #17)
> > Observation 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;

Thanks, I stared too much at the 2nd multiplication.

> 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.

-Wstrict-overflow=<N> used to issue a warning like "assuming signed overflow
might not occur", and maybe I was misguidid by the missing warning.

Hence this is just a "missing warning" type of PR, if at all.

Reply via email to