[Bug c++/84814] Type of arithmetic expression
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Mar 10 23:48:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84814
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
the integral promotions (4.5) shall be performed on both operands
This means uint16_t is promoted to int first.
So:
if((curtime - LastTime) >= Request)
Is really:
if(((int)curtime - (int)LastTime) >= (int)Request)
In the second case the code is equivalent to:
if((int)(uint16_t)((int)curtime - (int)LastTime) >= (int)Request)
More information about the Gcc-bugs
mailing list