This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/19437] wrong warning when assigning negative value to int
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Jan 2005 19:50:55 -0000
- Subject: [Bug c++/19437] wrong warning when assigning negative value to int
- References: <20050114093847.19437.oliverst@online.de>
- Reply-to: gcc-bugzilla 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 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