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

schlie at comcast dot net gcc-bugzilla@gcc.gnu.org
Fri Jan 14 19:40:00 GMT 2005


------- Additional Comments From schlie at comcast dot net  2005-01-14 19:40 -------
(In reply to comment #3)
>          int val = i ? i : -1;
> 
> we convert it to unsigned because it gets promoted to unsigned because i is unsigned and then
> there is an implicit cast to int. so the type of "i ? i : -1" is unsigned and there is an implicit cast to int.

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?

which would seem fine, if the middle-end trasformed:

     w = (x ? y : z)  =>  w = (x ? (max y z)y : (max y z)z) 

internallly, or something like that.




-- 


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



More information about the Gcc-bugs mailing list