[Bug c++/83710] Unsigned with Signed multiplication followed by right shift

chanpreet.singh at nxp dot com gcc-bugzilla@gcc.gnu.org
Sun Jan 7 05:20:00 GMT 2018


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

--- Comment #8 from Chanpreet Singh <chanpreet.singh at nxp dot com> ---
(In reply to Jakub Jelinek from comment #7)
> You shouldn't read random blogs, but the standard of the language you are
> writing in.
> E.g. in n3797.pdf it is in [expr]/10:
> "Otherwise, the integral promotions (4.5) shall be performed on both
> operands. Then the following rules shall be applied to the promoted operands:
> — If both operands have the same type, no further conversion is needed.
> — Otherwise, if both operands have signed integer types or both have
> unsigned integer types, the operand with the type of lesser integer
> conversion rank shall be converted to the type of the operand with greater
> rank.
> — Otherwise, if the operand that has unsigned integer type has rank greater
> than or equal to the rank of the type of the other operand, the operand with
> signed integer type shall be converted to the type of the operand with
> unsigned integer type.
> — Otherwise, if the type of the operand with signed integer type can
> represent all of the values of the type of the operand with unsigned integer
> type, the operand with unsigned integer type shall be converted to the type
> of the operand with signed integer type.
> — Otherwise, both operands shall be converted to the unsigned integer type
> corresponding to the type of the operand with signed integer type.

Thanks! Found more pointers in the documentation. I usually follow "preserve
signedness of the type" but thats not the case here.


More information about the Gcc-bugs mailing list