[Bug c++/19437] wrong warning when assigning negative value to int

pinskia at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Jan 14 19:51:00 GMT 2005


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-14 19:50 -------
(In reply to comment #4)
> Then either the semantic definition of the middle-end's w = (x ? y : z) needs to preserve y : z types,
> or it can not be considered equilvelent to if(x){ w = y; w = z;}, it would seem?

The middle-end here has nothing to do with it, this is all C/C++ standard behavior and nothing else.
look the C standard does not talk about "=?:" but only the types of ?: and = separately.  unsigned is 
higher in the promotion than signed int which is where the warning comes from and the type of the 
whole expression (a?i:j) is unsigned because that the lowest type which both can be promoted to.

then there is an explicate cast from unsigned to int because we are assigning to an int.

This again has nothing to do with the middle-end and just the rules in C/C++ of how to deal with the 
different type objects in the "?:".

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19437



More information about the Gcc-bugs mailing list