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

2005-01-14 Thread schlie at comcast dot net
--- Additional Comments From schlie at comcast dot net 2005-01-15 02:38 --- (In reply to comment #5) Yes, I apologize, I misread the the report/answer, you are of course correct. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19437

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

2005-01-14 Thread pinskia at gcc dot gnu dot org
--- 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 wou

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

2005-01-14 Thread schlie at comcast dot net
--- 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 "

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

2005-01-14 Thread pinskia at gcc dot gnu dot org
--- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-14 14:30 --- 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 t

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

2005-01-14 Thread oliverst at online dot de
--- Additional Comments From oliverst at online dot de 2005-01-14 14:26 --- Ah, OK. Why is there warning at all. "-1" is being assigned to an "int" and not to an "unsigned int". Writing it without the "? :" operator, the following code should be the same. unsigned int i = 0; int val; if

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

2005-01-14 Thread pinskia at gcc dot gnu dot org
--- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-14 13:19 --- The warning is correct. To get a warning in C you have to use -Wconversion. pr19437.c:4: warning: negative integer implicitly converted to unsigned type -- What|Removed