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: "schlie at comcast dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Jan 2005 19:40:16 -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 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